cel

package
v0.0.0-...-ffdfc10 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cel provides helpers for working with CEL expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	ast.ExprFactory
	// contains filtered or unexported fields
}

Builder allows building CEL expressions programmatically.

func NewBuilder

func NewBuilder(env *cel.Env) *Builder

NewBuilder creates a new builder.

func (*Builder) NextID

func (b *Builder) NextID() int64

NextID returns the next unique ID.

func (*Builder) ToBooleanExpression

func (b *Builder) ToBooleanExpression(expr ast.Expr) (*Expression, error)

ToBooleanExpression converts the AST to a boolean expression.

type Expression

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

Expression is a CEL expression that can be marshaled/unmarshaled as part of the resource.

func MustExpression

func MustExpression(expr Expression, err error) Expression

MustExpression panics if the expression cannot be parsed.

func ParseBooleanExpression

func ParseBooleanExpression(expression string, env *cel.Env) (Expression, error)

ParseBooleanExpression parses the expression and asserts the result to boolean.

func (Expression) EvalBool

func (expr Expression) EvalBool(env *cel.Env, values map[string]any) (bool, error)

EvalBool evaluates the expression in the given environment.

func (Expression) IsZero

func (expr Expression) IsZero() bool

IsZero returns true if the expression is zero.

func (Expression) MarshalProto

func (expr Expression) MarshalProto() ([]byte, error)

MarshalProto marshals the expression to proto.

func (Expression) MarshalText

func (expr Expression) MarshalText() ([]byte, error)

MarshalText marshals the expression to text.

func (*Expression) Merge

func (expr *Expression) Merge(v any) error

Merge imlements merge.Mergeable.

func (*Expression) ParseBool

func (expr *Expression) ParseBool(env *cel.Env) error

ParseBool parses the expression and asserts the result to boolean.

ParseBoolean can be used after unmarshaling the expression from text.

func (Expression) String

func (expr Expression) String() string

String implements fmt.Stringer.

func (*Expression) UnmarshalProto

func (expr *Expression) UnmarshalProto(data []byte) error

UnmarshalProto unmarshals the expression from proto.

func (*Expression) UnmarshalText

func (expr *Expression) UnmarshalText(data []byte) error

UnmarshalText unmarshals the expression from text.

Directories

Path Synopsis
Package celenv provides standard CEL environments to evaluate CEL expressions.
Package celenv provides standard CEL environments to evaluate CEL expressions.

Jump to

Keyboard shortcuts

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