Help us shape the future of Go! Take the 2026 Go Developer Survey

expression

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0, MIT Imports: 19 Imported by: 0

Documentation

Overview

Package expression evaluates CEL expressions in decoded configuration values.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingReference = errors.New("required reference is missing")

ErrMissingReference identifies an absent expression key or attribute.

Functions

func Check

func Check(value any, allowedRoots ...string) error

Check validates expressions without reading their context values. Only the named context roots are allowed; passing no roots permits literal expressions.

func Env

func Env() map[string]any

Env captures the process environment in a context suitable for Eval.

func Environment

func Environment(value any) (map[string]string, error)

Environment captures only environment keys referenced by expressions. Missing keys remain absent so optional lookups can use their fallback. Dynamic key access, or use of the whole env object, conservatively captures all keys.

func Eval

func Eval(value any, contexts map[string]any) (any, error)

Eval resolves templates once, without changing value or contexts. Whole-value expressions retain their native type; expressions within text must be scalars. Contexts contain only data, with environment values represented as strings.

func Has

func Has(value any) bool

Has reports whether a value contains an unescaped expression opener. Malformed expressions also return true so they can be rejected by Check.

func Roots

func Roots(value any) ([]string, error)

Roots returns the sorted context roots referenced by a value's expressions.

func Uses

func Uses(value any, root, field string) ([]string, bool, error)

Uses reports the keys of a context root whose field expressions read, such as the inputs whose facts are used. Reading a key's whole value counts as reading the field; a dynamic key or a use of the whole root reports all.

Types

This section is empty.

Jump to

Keyboard shortcuts

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