expr

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 11 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

View Source
var (

	// DefaultEnvironment is a shared environment instance for simple use cases.
	// This allows multiple compilations to reuse the same environment efficiently.
	DefaultEnvironment = MustNewEnvironment()
)

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() *Environment

MustNewEnvironment creates a new Environment and panics on error.

func NewEnvironment added in v0.16.0

func NewEnvironment() (*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.

Jump to

Keyboard shortcuts

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