policy

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy interface {
	// Reload will reload the policy. Subsequent calls to Evaluate will run
	// the newly loaded policy, if reloading was successful. If reloading fails,
	// the old state is kept.
	Reload() error

	// Evaluate the underlying policy. See rego docs for more info.
	Eval(ctx context.Context, options ...rego.EvalOption) (rego.ResultSet, error)
}

Policy wraps a OPA policy and supports reloading at runtime.

func LoadFromFile

func LoadFromFile(policyPath, policyQuery string) (Policy, error)

LoadFromFile creates a reloadable policy from a rego file.

func WrapForTest

func WrapForTest(query *rego.PreparedEvalQuery) Policy

WrapForTest creates a policy from a pepared query, useful for testing. Do not use this in code -- the policy will not be able to reload.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL