Documentation ¶
Overview ¶
Package loader contains utilities for loading files into OPA.
Index ¶
- func AsBundle(path string) (*bundle.Bundle, error)
- func CleanPath(path string) string
- func Dirs(paths []string) []string
- func FilteredPaths(paths []string, filter Filter) ([]string, error)
- func FilteredPathsFS(fsys fs.FS, paths []string, filter Filter) ([]string, error)
- func GetBundleDirectoryLoader(path string) (bundle.DirectoryLoader, bool, error)
- func GetBundleDirectoryLoaderFS(fsys fs.FS, path string, filter Filter) (bundle.DirectoryLoader, bool, error)
- func GetBundleDirectoryLoaderWithFilter(path string, filter Filter) (bundle.DirectoryLoader, bool, error)
- func Paths(path string, recurse bool) (paths []string, err error)
- func Schemas(schemaPath string) (*ast.SchemaSet, error)
- func SplitPrefix(path string) ([]string, string)
- type Errors
- type FileLoader
- type Filter
- type RegoFile
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsBundle ¶ added in v0.14.0
AsBundle loads a path as a bundle. If it is a single file it will be treated as a normal tarball bundle. If a directory is supplied it will be loaded as an unzipped bundle tree. Deprecated: Use FileLoader.AsBundle() instead.
func CleanPath ¶ added in v0.5.9
CleanPath returns the normalized version of a path that can be used as an identifier.
func Dirs ¶ added in v0.24.0
Dirs resolves filepaths to directories. It will return a list of unique directories.
func FilteredPaths ¶ added in v0.22.0
FilteredPaths is the same as FilterPathsFS using the current diretory file system
func FilteredPathsFS ¶ added in v0.44.0
FilteredPathsFS return a list of files from the specified paths while applying the given filters. If any filter returns true, the file/directory is excluded.
func GetBundleDirectoryLoader ¶ added in v0.22.0
func GetBundleDirectoryLoader(path string) (bundle.DirectoryLoader, bool, error)
GetBundleDirectoryLoader returns a bundle directory loader which can be used to load files in the directory
func GetBundleDirectoryLoaderFS ¶ added in v0.52.0
func GetBundleDirectoryLoaderFS(fsys fs.FS, path string, filter Filter) (bundle.DirectoryLoader, bool, error)
GetBundleDirectoryLoaderFS returns a bundle directory loader which can be used to load files in the directory.
func GetBundleDirectoryLoaderWithFilter ¶ added in v0.44.0
func GetBundleDirectoryLoaderWithFilter(path string, filter Filter) (bundle.DirectoryLoader, bool, error)
GetBundleDirectoryLoaderWithFilter returns a bundle directory loader which can be used to load files in the directory after applying the given filter.
func Paths ¶
Paths returns a sorted list of files contained at path. If recurse is true and path is a directory, then Paths will walk the directory structure recursively and list files at each level.
func SplitPrefix ¶
SplitPrefix returns a tuple specifying the document prefix and the file path.
Types ¶
type FileLoader ¶ added in v0.16.0
type FileLoader interface { All(paths []string) (*Result, error) Filtered(paths []string, filter Filter) (*Result, error) AsBundle(path string) (*bundle.Bundle, error) WithReader(io.Reader) FileLoader WithFS(fs.FS) FileLoader WithMetrics(metrics.Metrics) FileLoader WithFilter(Filter) FileLoader WithBundleVerificationConfig(*bundle.VerificationConfig) FileLoader WithSkipBundleVerification(bool) FileLoader WithProcessAnnotation(bool) FileLoader WithCapabilities(*ast.Capabilities) FileLoader WithJSONOptions(*astJSON.Options) FileLoader }
FileLoader defines an interface for loading OPA data files and Rego policies.
func NewFileLoader ¶ added in v0.16.0
func NewFileLoader() FileLoader
NewFileLoader returns a new FileLoader instance.
type Filter ¶ added in v0.8.2
type Filter = filter.LoaderFilter
Filter defines the interface for filtering files during loading. If the filter returns true, the file should be excluded from the result.
func GlobExcludeName ¶ added in v0.8.2
GlobExcludeName excludes files and directories whose names do not match the shell style pattern at minDepth or greater.
type RegoFile ¶
RegoFile represents the result of loading a single Rego source file.
func RegoWithOpts ¶ added in v0.28.0
func RegoWithOpts(path string, opts ast.ParserOptions) (*RegoFile, error)
RegoWithOpts returns a RegoFile object loaded from the given path.
type Result ¶
type Result struct { Documents map[string]interface{} Modules map[string]*RegoFile // contains filtered or unexported fields }
Result represents the result of successfully loading zero or more files.
func All ¶
All returns a Result object loaded (recursively) from the specified paths. Deprecated: Use FileLoader.Filtered() instead.
func AllRegos ¶
AllRegos returns a Result object loaded (recursively) with all Rego source files from the specified paths.
func Filtered ¶ added in v0.8.2
Filtered returns a Result object loaded (recursively) from the specified paths while applying the given filters. If any filter returns true, the file/directory is excluded. Deprecated: Use FileLoader.Filtered() instead.
func (*Result) Compiler ¶ added in v0.10.0
Compiler returns a Compiler object with the compiled modules from this loader result.
func (*Result) ParsedModules ¶ added in v0.10.0
ParsedModules returns the parsed modules stored on the result.