Documentation
¶
Index ¶
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. Note: at the moment, this is not safe for concurrent use.
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 (c *EvaluableCondition) CastContextToTypedParameters(contextMap map[string]any) (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 (c *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 (c *EvaluableCondition) Evaluate(contextMaps ...map[string]any) (EvaluationResult, error)
Evaluate evalutes the provided CEL condition expression with a CEL environment constructed from the condition's parameter type definitions and using the context provided. If more than one source of context is provided, and if the keys provided in those context(s) are overlapping, then the overlapping key for the last most context wins.
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