Help us shape the future of Go! Take the 2026 Go Developer Survey

sourcepolicy

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 9 Imported by: 71

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 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