sourcepolicy

package
v0.13.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSourceDenied is returned by the policy engine when a source is denied by the policy.
	ErrSourceDenied = errors.New("source denied by policy")

	// ErrTooManyOps is returned by the policy engine when there are too many converts for a single source op.
	ErrTooManyOps = errors.New("too many operations")
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the source policy engine. It is responsible for evaluating a source policy against a source operation. Create one with `NewEngine`

Rule matching is delegated to the `Matcher` interface. Mutations are delegated to the `Mutater` interface.

func NewEngine

func NewEngine(pol []*spb.Policy) *Engine

NewEngine creates a new source policy engine.

func (*Engine) Evaluate

func (e *Engine) Evaluate(ctx context.Context, op *pb.SourceOp) (bool, error)

Evaluate evaluates a source operation against the policy.

Policies are re-evaluated for each convert rule. Evaluate will error if the there are too many converts for a single source op to prevent infinite loops. This function may error out even if the op was mutated, in which case `true` will be returned along with the error.

An error is returned when the source is denied by the policy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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