Documentation ¶
Index ¶
- Variables
- type Decision
- type EvalOption
- type LintError
- type LintRule
- type MultiError
- type Policy
- func (policy Policy) Decide(ctx context.Context, input interface{}, opts ...EvalOption) (*Decision, error)
- func (policy Policy) Eval(ctx context.Context, query string, input interface{}, opts ...EvalOption) (interface{}, error)
- func (policy Policy) Modules() map[string]*ast.Module
- func (policy Policy) Source() map[string]string
- type Status
- type Violation
Constants ¶
This section is empty.
Variables ¶
var ErrLint = LintError("linting error")
var ErrNoPolicies = errors.New("no rego policies found")
Functions ¶
This section is empty.
Types ¶
type Decision ¶
type Decision struct { Status Status `json:"status"` Reason string `json:"reason,omitempty"` EnabledRules []string `json:"enabled_rules,omitempty"` HardFailures []Violation `json:"hard_failures,omitempty"` SoftFailures []Violation `json:"soft_failures,omitempty"` }
Decision is a circleci flavoured output representing a policy decision.
type EvalOption ¶ added in v0.0.67
type EvalOption func(*evalOptions)
func Meta ¶ added in v0.0.67
func Meta(value interface{}) EvalOption
Meta is an option that sets the data.meta property during policy evaluation.
type LintRule ¶
func AllowedPackages ¶
func DisallowMetaBranch ¶ added in v0.0.583
func DisallowMetaBranch() LintRule
type MultiError ¶
type MultiError []error
func (MultiError) Error ¶
func (err MultiError) Error() string
func (MultiError) Unwrap ¶ added in v0.0.583
func (err MultiError) Unwrap() []error
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
func LoadPolicyFromFS ¶ added in v0.0.137
LoadPolicyFromFS takes a filesystem path to load policy files from. It returns a parsed policy. If the path is a file that policy is loaded as a bundle of 1 file. If the path is a directory that directory is walked recursively searching for all rego files. If the bundle is empty an error is returned.
func ParseBundle ¶
ParseBundle will restrict package name to 'org'. This allows us to more easily extract information from the OPA output after evaluating a policy, because we know what the keys will be in the map that contains the results (e.g., map["org"]["enable_rule"] to find enabled rules).
func (Policy) Decide ¶
func (policy Policy) Decide(ctx context.Context, input interface{}, opts ...EvalOption) (*Decision, error)
Decide takes an input and evaluates it against a policy. Evaluation options will be passed down to policy.Eval
func (Policy) Eval ¶
func (policy Policy) Eval(ctx context.Context, query string, input interface{}, opts ...EvalOption) (interface{}, error)
Eval will run native OPA query against your document, input, and apply any evaluation options. It returns raw OPA expression values.