policy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package policy compiles and evaluates the Rego policies that make each hook's decision.

Index

Constants

This section is empty.

Variables

View Source
var ErrUndefined = errors.New("policy result is undefined")

ErrUndefined is returned when the policy defines no result for an input.

Functions

func Eval

func Eval[T any](ctx context.Context, e *Engine, input any) (T, error)

Eval evaluates the policy against input and decodes the result into T. It returns ErrUndefined when the policy defines no result for the input.

Types

type Engine

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

Engine is a compiled policy query. It is safe for concurrent use.

func Compile

func Compile(ctx context.Context, name, src, query string) (*Engine, error)

Compile compiles query against the policy source, which must be Rego v1 and define the rule query refers to, such as data.example.result. name is used in error messages.

func Load

func Load(ctx context.Context, path, query string) (*Engine, error)

Load reads the policy at path and compiles query against it.

Jump to

Keyboard shortcuts

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