package file

import "github.com/open-policy-agent/opa/internal/file"

Index

Types

type Descriptor

type Descriptor struct {
	// contains filtered or unexported fields
}

Descriptor contains information about a file and can be used to read the file contents.

func (*Descriptor) Close

func (d *Descriptor) Close() error

Close the file, on some Loader implementations this might be a no-op. It should *always* be called regardless of file.

func (*Descriptor) Path

func (d *Descriptor) Path() string

Path returns the path of the file.

func (*Descriptor) Read

func (d *Descriptor) Read(dest io.Writer, n int64) (int64, error)

Read will read all the contents from the file the Descriptor refers to into the dest writer up n bytes. Will return an io.EOF error if EOF is encountered before n bytes are read.

type DirectoryLoader

type DirectoryLoader interface {
	// NextFile must return io.EOF if there is no next value. The returned
	// descriptor should *always* be closed when no longer needed.
	NextFile() (*Descriptor, error)
}

DirectoryLoader defines an interface which can be used to load files from a directory by iterating over each one in the tree.

func NewDirectoryLoader

func NewDirectoryLoader(root string) DirectoryLoader

NewDirectoryLoader returns a basic DirectoryLoader implementation that will load files from a given root directory path.

func NewTarballLoader

func NewTarballLoader(r io.Reader) DirectoryLoader

NewTarballLoader returns a new DirectoryLoader that reads files out of a gzipped tar archive.

Source Files

loader.go

Directories

PathSynopsis
internal/file/archive
internal/file/urlPackage url contains helpers for dealing with file paths and URLs.
Version
v0.14.2
Published
Oct 4, 2019
Platform
js/wasm
Imports
8 packages
Last checked
1 hour ago

Tools for package owners.