expr

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package expr provides CEL (Common Expression Language) functionality for evaluating expressions against file paths and YAML content.

It creates CEL environments with custom functions for:

  • File path operations (pathBase, pathDir, pathExt)
  • YAML content extraction (yamlPath)

CEL expressions have access to variables:

  • `files` (list<string>): All file paths in directory
  • `dir` (string): The directory path being processed

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToCELValue

func ConvertToCELValue(value any) ref.Val

ConvertToCELValue converts a Go value to a CEL value. Handles common YAML types and returns null for unsupported types.

Types

type Environment added in v0.16.0

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

Environment provides a thread-safe wrapper around a *cel.Env.

func MustNewEnvironment added in v0.16.0

func MustNewEnvironment(opts ...cel.EnvOption) *Environment

MustNewEnvironment creates a new Environment and panics on error.

func NewEnvironment added in v0.16.0

func NewEnvironment(opts ...cel.EnvOption) (*Environment, error)

NewEnvironment creates a new Environment.

func (*Environment) Compile added in v0.16.0

func (e *Environment) Compile(expression string) (cel.Program, error)

Compile compiles a CEL expression and returns a program.

type LazyProgram added in v0.26.0

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

LazyProgram provides thread-safe lazy compilation of a CEL expression. The expression is compiled at most once, even when accessed concurrently.

func NewLazyProgram added in v0.26.0

func NewLazyProgram(expression string, env *Environment) *LazyProgram

NewLazyProgram creates a new LazyProgram that will compile the given expression using the provided environment when Get() is first called.

func (*LazyProgram) Get added in v0.26.0

func (lp *LazyProgram) Get() (cel.Program, error)

Get returns the compiled program, compiling it on the first call. Subsequent calls return the cached result.

func (*LazyProgram) IsCompiled added in v0.26.0

func (lp *LazyProgram) IsCompiled() bool

IsCompiled returns true if the program has been compiled.

Jump to

Keyboard shortcuts

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