package loader
import "github.com/open-policy-agent/opa/loader"
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the github.com/open-policy-agent/opa/v1 package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.
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
- func Rego(path string) (*RegoFile, error)
- func RegoWithOpts(path string, opts ast.ParserOptions) (*RegoFile, error)
- type Result
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 Dirs ¶
Dirs resolves filepaths to directories. It will return a list of unique directories.
func FilteredPaths ¶
FilteredPaths is the same as FilterPathsFS using the current diretory file system
func FilteredPathsFS ¶
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 ¶
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 ¶
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 ¶
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 Schemas ¶
Schemas loads a schema set from the specified file path.
func SplitPrefix ¶
SplitPrefix returns a tuple specifying the document prefix and the file path.
Types ¶
type Errors ¶
Errors is a wrapper for multiple loader errors.
type FileLoader ¶
type FileLoader = v1.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 is deprecated. Use RegoWithOpts instead.
func RegoWithOpts ¶
func RegoWithOpts(path string, opts ast.ParserOptions) (*RegoFile, error)
RegoWithOpts returns a RegoFile object loaded from the given path.
type Result ¶
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.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
loader/extension | Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. |
loader/filter | Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. |
- Version
- v1.4.2 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 hours ago –
Tools for package owners.