cel

package
v0.3.108 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCompositeCostEstimator

func NewCompositeCostEstimator(estimators ...checker.CostEstimator) checker.CostEstimator

Types

type CEL

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

func NewCEL

func NewCEL(objectCache objectcache.ObjectCache, cfg config.Config) (*CEL, error)

func (*CEL) CreateEvalContext added in v0.3.108

func (c *CEL) CreateEvalContext(event *events.EnrichedEvent) map[string]any

CreateEvalContext builds a CEL evaluation context for the given event. The returned map is safe to reuse across multiple sequential EvaluateRuleWithContext calls for the same event — program.Eval reads but does not mutate it.

func (*CEL) EvaluateExpression

func (c *CEL) EvaluateExpression(event *events.EnrichedEvent, expression string) (string, error)

func (*CEL) EvaluateRule

func (c *CEL) EvaluateRule(event *events.EnrichedEvent, expressions []typesv1.RuleExpression) (bool, error)

func (*CEL) EvaluateRuleWithContext added in v0.3.108

func (c *CEL) EvaluateRuleWithContext(evalContext map[string]any, eventType utils.EventType, expressions []typesv1.RuleExpression) (bool, error)

EvaluateRuleWithContext evaluates expressions against a pre-built evaluation context. Callers who process multiple rules for the same event should build the context once via CreateEvalContext and reuse it here to avoid per-rule allocation.

func (*CEL) RegisterCustomType

func (c *CEL) RegisterCustomType(eventType utils.EventType, obj interface{}) error

func (*CEL) RegisterEventConverter added in v0.3.31

func (c *CEL) RegisterEventConverter(eventType utils.EventType, converter func(utils.K8sEvent) utils.K8sEvent)

func (*CEL) RegisterHelper

func (c *CEL) RegisterHelper(function cel.EnvOption) error

type CompositeCostEstimator

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

CompositeCostEstimator holds multiple estimators and queries them in order.

func (*CompositeCostEstimator) EstimateCallCost

func (c *CompositeCostEstimator) EstimateCallCost(function, overloadID string, target *checker.AstNode, args []checker.AstNode) *checker.CallEstimate

EstimateCallCost iterates through its estimators and returns the first non-nil estimate.

func (*CompositeCostEstimator) EstimateSize

func (c *CompositeCostEstimator) EstimateSize(element checker.AstNode) *checker.SizeEstimate

EstimateSize iterates through its estimators for a size estimate.

type RuleEvaluator added in v0.3.31

type RuleEvaluator interface {
	EvaluateRule(event *events.EnrichedEvent, expressions []typesv1.RuleExpression) (bool, error)
	EvaluateRuleWithContext(evalContext map[string]any, eventType utils.EventType, expressions []typesv1.RuleExpression) (bool, error)
	EvaluateExpression(event *events.EnrichedEvent, expression string) (string, error)
	CreateEvalContext(event *events.EnrichedEvent) map[string]any
	RegisterHelper(function cel.EnvOption) error
	RegisterCustomType(eventType utils.EventType, obj interface{}) error
	RegisterEventConverter(eventType utils.EventType, converter func(utils.K8sEvent) utils.K8sEvent)
}

Directories

Path Synopsis
k8s
net

Jump to

Keyboard shortcuts

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