caveats

package
v1.29.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And added in v1.15.0

And `&&`'s together two caveat expressions. If one expression is nil, the other is returned.

func CaveatAsExpr added in v1.15.0

func CaveatAsExpr(caveat *core.ContextualizedCaveat) *core.CaveatExpression

CaveatAsExpr wraps a contextualized caveat into a caveat expression.

func CaveatExprForTesting added in v1.15.0

func CaveatExprForTesting(name string) *core.CaveatExpression

CaveatExprForTesting returns a CaveatExpression referencing a caveat with the given name and empty context.

func CaveatForTesting added in v1.15.0

func CaveatForTesting(name string) *core.ContextualizedCaveat

CaveatForTesting returns a new ContextualizedCaveat for testing, with empty context.

func Invert added in v1.15.0

Invert returns the caveat expression with a `!` placed in front of it. If the expression is nil, returns nil.

func Or added in v1.15.0

Or `||`'s together two caveat expressions. If one expression is nil, the other is returned.

func ShortcircuitedOr added in v1.15.0

func ShortcircuitedOr(first *core.CaveatExpression, second *core.CaveatExpression) *core.CaveatExpression

ShortcircuitedOr combines two caveat expressions via an `||`. If one of the expressions is nil, then the entire expression is *short-circuited*, and a nil is returned.

func Subtract added in v1.15.0

func Subtract(caveat *core.CaveatExpression, subtracted *core.CaveatExpression) *core.CaveatExpression

Subtract returns a caveat expression representing the subtracted expression subtracted from the given expression.

Types

type EvaluationErr added in v1.16.2

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

EvaluationErr is an error in evaluation of a caveat expression.

func NewEvaluationErr added in v1.16.2

func NewEvaluationErr(caveatExpr *core.CaveatExpression, err caveats.EvaluationErr) EvaluationErr

func (EvaluationErr) DetailsMetadata added in v1.16.2

func (err EvaluationErr) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (EvaluationErr) GRPCStatus added in v1.16.2

func (err EvaluationErr) GRPCStatus() *status.Status

func (EvaluationErr) MarshalZerologObject added in v1.16.2

func (err EvaluationErr) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog.LogObjectMarshaler

type ExpressionResult added in v1.15.0

type ExpressionResult interface {
	// Value is the resolved value for the expression. For partially applied expressions, this value will be false.
	Value() bool

	// IsPartial returns whether the expression was only partially applied.
	IsPartial() bool

	// MissingVarNames returns the names of the parameters missing from the context.
	MissingVarNames() ([]string, error)

	// ContextValues returns the context values used when computing this result.
	ContextValues() map[string]any

	// ContextStruct returns the context values as a structpb Struct.
	ContextStruct() (*structpb.Struct, error)

	// ExpressionString returns the human-readable expression for the caveat expression.
	ExpressionString() (string, error)
}

ExpressionResult is the result of a caveat expression being run.

func RunCaveatExpression added in v1.15.0

func RunCaveatExpression(
	ctx context.Context,
	expr *core.CaveatExpression,
	context map[string]any,
	reader datastore.CaveatReader,
	debugOption RunCaveatExpressionDebugOption,
) (ExpressionResult, error)

RunCaveatExpression runs a caveat expression over the given context and returns the result.

type ParameterTypeError added in v1.16.2

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

ParameterTypeError is a type error in constructing a parameter from a value.

func NewParameterTypeError added in v1.16.2

func NewParameterTypeError(caveatExpr *core.CaveatExpression, err error) ParameterTypeError

func (ParameterTypeError) DetailsMetadata added in v1.16.2

func (err ParameterTypeError) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ParameterTypeError) GRPCStatus added in v1.16.2

func (err ParameterTypeError) GRPCStatus() *status.Status

func (ParameterTypeError) MarshalZerologObject added in v1.16.2

func (err ParameterTypeError) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog.LogObjectMarshaler

type RunCaveatExpressionDebugOption added in v1.15.0

type RunCaveatExpressionDebugOption int

RunCaveatExpressionDebugOption are the options for running caveat expression evaluation with debugging enabled or disabled.

const (
	// RunCaveatExpressionNoDebugging runs the evaluation without debugging enabled.
	RunCaveatExpressionNoDebugging RunCaveatExpressionDebugOption = 0

	// RunCaveatExpressionNoDebugging runs the evaluation with debugging enabled.
	RunCaveatExpressionWithDebugInformation RunCaveatExpressionDebugOption = 1
)

Jump to

Keyboard shortcuts

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