Documentation ¶
Index ¶
- Variables
- func NewEvaluationError(condition string, cause error) error
- type CompilationError
- type EvaluableCondition
- func (e *EvaluableCondition) CastContextToTypedParameters(contextMap map[string]*structpb.Value) (map[string]any, error)
- func (e *EvaluableCondition) Compile() error
- func (e *EvaluableCondition) Evaluate(ctx context.Context, contextMaps ...map[string]*structpb.Value) (EvaluationResult, error)
- func (e *EvaluableCondition) WithInterruptCheckFrequency(checkFrequency uint) *EvaluableCondition
- func (e *EvaluableCondition) WithMaxEvaluationCost(cost uint64) *EvaluableCondition
- func (e *EvaluableCondition) WithTrackEvaluationCost() *EvaluableCondition
- type EvaluationError
- type EvaluationResult
- type ParameterTypeError
Constants ¶
This section is empty.
Variables ¶
var ErrEvaluationFailed = fmt.Errorf("failed to evaluate relationship condition")
Functions ¶
func NewEvaluationError ¶
Types ¶
type CompilationError ¶
func (*CompilationError) Error ¶
func (e *CompilationError) Error() string
func (*CompilationError) Unwrap ¶
func (e *CompilationError) Unwrap() error
type EvaluableCondition ¶
EvaluableCondition represents a condition that can eventually be evaluated given a CEL expression and a set of parameters. Calling .Evaluate() will optionally call .Compile() which validates and compiles the expression and parameter type definitions if it hasn't been done already.
func NewCompiled ¶
func NewCompiled(condition *openfgav1.Condition) (*EvaluableCondition, error)
NewCompiled returns a new EvaluableCondition with a validated and compiled expression.
func NewUncompiled ¶
func NewUncompiled(condition *openfgav1.Condition) *EvaluableCondition
NewUncompiled returns a new EvaluableCondition that has not validated and compiled its expression.
func (*EvaluableCondition) CastContextToTypedParameters ¶
func (e *EvaluableCondition) CastContextToTypedParameters(contextMap map[string]*structpb.Value) (map[string]any, error)
CastContextToTypedParameters converts the provided context to typed condition parameters and returns an error if any additional context fields are provided that are not defined by the evaluable condition.
func (*EvaluableCondition) Compile ¶
func (e *EvaluableCondition) Compile() error
Compile compiles a condition expression with a CEL environment constructed from the condition's parameter type definitions into a valid AST that can be evaluated at a later time.
func (*EvaluableCondition) Evaluate ¶
func (e *EvaluableCondition) Evaluate( ctx context.Context, contextMaps ...map[string]*structpb.Value, ) (EvaluationResult, error)
Evaluate evaluates the provided CEL condition expression with a CEL environment constructed from the condition's parameter type definitions and using the context maps provided. If more than one source map of context is provided, and if the keys provided in those map context(s) are overlapping, then the overlapping key for the last most context wins.
func (*EvaluableCondition) WithInterruptCheckFrequency ¶ added in v1.4.1
func (e *EvaluableCondition) WithInterruptCheckFrequency(checkFrequency uint) *EvaluableCondition
WithInterruptCheckFrequency defines the upper limit on the number of iterations within a CEL comprehension to evaluate before CEL will interrupt evaluation and check for cancellation. within a comprehension on the EvaluableCondition and returns the mutated EvaluableCondition. The expectation is that this is called on the Uncompiled condition because it modifies the behavior of the CEL program that is constructed after Compile.
func (*EvaluableCondition) WithMaxEvaluationCost ¶
func (e *EvaluableCondition) WithMaxEvaluationCost(cost uint64) *EvaluableCondition
WithMaxEvaluationCost enables CEL evaluation cost enforcement on the EvaluableCondition and returns the mutated EvaluableCondition. The expectation is that this is called on the Uncompiled condition because it modifies the behavior of the CEL program that is constructed after Compile.
func (*EvaluableCondition) WithTrackEvaluationCost ¶
func (e *EvaluableCondition) WithTrackEvaluationCost() *EvaluableCondition
WithTrackEvaluationCost enables CEL evaluation cost on the EvaluableCondition and returns the mutated EvaluableCondition. The expectation is that this is called on the Uncompiled condition because it modifies the behavior of the CEL program that is constructed after Compile.
type EvaluationError ¶
func (*EvaluationError) Error ¶
func (e *EvaluationError) Error() string
func (*EvaluationError) Unwrap ¶
func (e *EvaluationError) Unwrap() error
type EvaluationResult ¶
type ParameterTypeError ¶
func (*ParameterTypeError) Error ¶
func (e *ParameterTypeError) Error() string
func (*ParameterTypeError) Unwrap ¶
func (e *ParameterTypeError) Unwrap() error