cel

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnhancedCELEnvironment

func EnhancedCELEnvironment() (*cel.Env, error)

EnhancedCELEnvironment creates a CEL environment with additional functions for data operations

Types

type CacheConfig

type CacheConfig struct {
	MaxSize int           // Maximum number of cached programs
	TTL     time.Duration // Time to live for cached entries
}

CacheConfig holds configuration for the CEL cache

func DefaultCacheConfig

func DefaultCacheConfig() *CacheConfig

DefaultCacheConfig returns default cache configuration

type CacheStats

type CacheStats struct {
	Size      int     `json:"size"`
	MaxSize   int     `json:"maxSize"`
	HitCount  int64   `json:"hitCount"`
	MissCount int64   `json:"missCount"`
	HitRatio  float64 `json:"hitRatio"`
}

CacheStats represents cache performance statistics

type CachedProgram

type CachedProgram struct {
	Program  cel.Program
	AST      *cel.Ast
	CachedAt time.Time
	HitCount int64
	LastUsed time.Time
	ExprHash string
}

CachedProgram represents a compiled CEL program with metadata

type CompilationCache

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

CompilationCache provides thread-safe caching of compiled CEL expressions

func GetGlobalCache

func GetGlobalCache(env *cel.Env) *CompilationCache

GetGlobalCache returns the global CEL compilation cache

func NewCompilationCache

func NewCompilationCache(config *CacheConfig, env *cel.Env, logger observability.Logger) *CompilationCache

NewCompilationCache creates a new CEL compilation cache

func (*CompilationCache) Clear

func (cc *CompilationCache) Clear()

Clear removes all entries from the cache

func (*CompilationCache) CompileAndCache

func (cc *CompilationCache) CompileAndCache(
	ctx context.Context,
	expression, expressionType string,
) (*CachedProgram, error)

CompileAndCache compiles a CEL expression and caches the result

func (*CompilationCache) Evaluate

func (cc *CompilationCache) Evaluate(
	ctx context.Context,
	expression, expressionType string,
	vars map[string]any,
) (any, error)

Evaluate compiles (with caching) and evaluates a CEL expression

func (*CompilationCache) EvaluateCondition

func (cc *CompilationCache) EvaluateCondition(
	ctx context.Context,
	expression string,
	vars map[string]any,
) (bool, error)

EvaluateCondition evaluates a boolean CEL expression with caching

func (*CompilationCache) EvaluateFilter

func (cc *CompilationCache) EvaluateFilter(
	ctx context.Context,
	expression string,
	vars map[string]any,
) (bool, error)

EvaluateFilter evaluates a filter CEL expression with caching

func (*CompilationCache) EvaluateTransform

func (cc *CompilationCache) EvaluateTransform(
	ctx context.Context,
	expression string,
	vars map[string]any,
) (any, error)

EvaluateTransform evaluates a transform CEL expression with caching

func (*CompilationCache) GetStats

func (cc *CompilationCache) GetStats() CacheStats

GetStats returns cache statistics

func (*CompilationCache) ProcessList

func (cc *CompilationCache) ProcessList(
	ctx context.Context,
	expression, expressionType string,
	items []any,
	baseVars map[string]any,
) ([]any, error)

ProcessList evaluates a CEL expression over a list of items with caching

func (*CompilationCache) Stop

func (cc *CompilationCache) Stop()

Stop terminates background maintenance goroutines.

type ErrEvaluationBlocked

type ErrEvaluationBlocked struct {
	Reason string
}

ErrEvaluationBlocked is a custom error to indicate that CEL evaluation cannot proceed because it is waiting on an external dependency, such as the output from a previous step.

func (*ErrEvaluationBlocked) Error

func (e *ErrEvaluationBlocked) Error() string

type Evaluator

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

Evaluator is responsible for CEL evaluation.

func New

func New(logger observability.Logger) (*Evaluator, error)

New creates a new Evaluator.

func (*Evaluator) Close

func (e *Evaluator) Close()

Close stops background goroutines and releases resources.

func (*Evaluator) EvaluateWhenCondition

func (e *Evaluator) EvaluateWhenCondition(ctx context.Context, when string, vars map[string]any) (bool, error)

EvaluateWhenCondition evaluates a step's `when` condition.

func (*Evaluator) ResolveWithInputs

func (e *Evaluator) ResolveWithInputs(
	ctx context.Context,
	with map[string]any,
	vars map[string]any,
) (map[string]any, error)

ResolveWithInputs resolves the `with` block for a step.

type ExpressionResolver

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

ExpressionResolver handles GitHub Actions-style expression resolution

func NewExpressionResolver

func NewExpressionResolver(k8sClient client.Client, namespace, storyRun string) *ExpressionResolver

NewExpressionResolver creates a new expression resolver

func (*ExpressionResolver) CheckDependencies

func (r *ExpressionResolver) CheckDependencies(ctx context.Context, dependencies []string) (bool, []string, error)

CheckDependencies checks if all step dependencies are satisfied

func (*ExpressionResolver) ResolveInputs

func (r *ExpressionResolver) ResolveInputs(ctx context.Context, inputs map[string]any) (map[string]any, error)

ResolveInputs resolves GitHub Actions-style expressions in step inputs

Jump to

Keyboard shortcuts

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