cel

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 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 added in v1.9.0

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

Builder allows building CEL expressions programmatically.

func NewBuilder added in v1.9.0

func NewBuilder(env *cel.Env) *Builder

NewBuilder creates a new builder.

func (*Builder) NextID added in v1.9.0

func (b *Builder) NextID() int64

NextID returns the next unique ID.

func (*Builder) ToBooleanExpression added in v1.9.0

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 added in v1.8.4

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 added in v1.8.2

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