Documentation
¶
Overview ¶
Package filesystem provides a PolicySource implementation that reads OPA policies from the local filesystem. Change detection is handled by the Manager.
Example usage:
source, err := filesystem.New("/path/to/policies",
filesystem.WithExtensions(".rego"),
filesystem.WithIncludeData(true),
)
if err != nil {
log.Fatal(err)
}
defer source.Close()
bundle, err := source.Fetch(ctx)
if err != nil {
log.Fatal(err)
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrChecksumMismatch is returned when a policy file's SHA-256 hash does not match the expected value. ErrChecksumMismatch = errors.New("policy file checksum mismatch") // ErrUnexpectedPolicyFile is returned when a policy file is found on disk but has no entry in the checksums manifest. ErrUnexpectedPolicyFile = errors.New("policy file not in checksums manifest") // ErrMissingPolicyFile is returned when an entry in the checksums manifest has no corresponding file on disk. ErrMissingPolicyFile = errors.New("expected policy file not found") )
var DefaultExtensions = []string{".rego"}
DefaultExtensions are the default file extensions to include.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(o *options)
Option is a functional option for configuring options.
func WithChecksums ¶
WithChecksums sets the checksums option.
func WithExtensions ¶
WithExtensions sets the extensions option.
func WithIncludeData ¶
func WithIncludeData() Option
WithIncludeData enables the includeData option.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source implements opa.PolicySource for filesystem-based policies. It reads .rego files from a directory. Change detection is handled by the Manager.
func New ¶
New creates a new filesystem policy source. The path can be a directory containing .rego files or a single .rego file.
func (*Source) Extensions ¶
Extensions returns the file extensions being watched as a slice.
func (*Source) ExtensionsIter ¶
ExtensionsIter returns an iterator over the file extensions being watched. This is more efficient when you don't need a slice.