package loader
import "github.com/open-policy-agent/opa/loader"
Package loader contains utilities for loading files into OPA.
Index ¶
- func AsBundle(path string) (*bundle.Bundle, error)
- func CleanPath(path string) string
- func Paths(path string, recurse bool) (paths []string, err error)
- func SplitPrefix(path string) ([]string, string)
- type Errors
- type FileLoader
- type Filter
- type RegoFile
- type Result
- func All(paths []string) (*Result, error)
- func AllRegos(paths []string) (*Result, error)
- func Filtered(paths []string, filter Filter) (*Result, error)
- func (l *Result) Compiler() (*ast.Compiler, error)
- func (l *Result) ParsedModules() map[string]*ast.Module
- func (l *Result) Store() (storage.Store, error)
Functions ¶
func AsBundle ¶
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 ¶
CleanPath returns the normalized version of a path that can be used as an identifier.
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 Errors ¶
type Errors []error
Errors is a wrapper for multiple loader errors.
func (Errors) Error ¶
type FileLoader ¶
type FileLoader interface { All(paths []string) (*Result, error) Filtered(paths []string, filter Filter) (*Result, error) AsBundle(path string) (*bundle.Bundle, error) WithMetrics(m metrics.Metrics) FileLoader }
FileLoader defines an interface for loading OPA data files and Rego policies.
func NewFileLoader ¶
func NewFileLoader() FileLoader
NewFileLoader returns a new FileLoader instance.
type Filter ¶
Filter defines the interface for filtering files during loading. If the filter returns true, the file should be excluded from the result.
func GlobExcludeName ¶
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 Rego ¶
Rego 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 ¶
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 ¶
Compiler returns a Compiler object with the compiled modules from this loader result.
func (*Result) ParsedModules ¶
ParsedModules returns the parsed modules stored on the result.
func (*Result) Store ¶
Store returns a Store object with the documents from this loader result.
Source Files ¶
- Version
- v0.19.2
- Published
- Apr 27, 2020
- Platform
- js/wasm
- Imports
- 16 packages
- Last checked
- 2 minutes ago –
Tools for package owners.