expreval

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package expreval evaluates the `${{ }}` expressions of a workflow file against an exprparser interpreter. Gitea evaluates them while planning a run, the runner while executing it, so both need the same splitting, interpolation and truthiness rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallsFunction

func CallsFunction(value string, names ...string) bool

CallsFunction reports whether any `${{ }}` expression in value calls one of the named functions.

func Match

func Match(value string, match func(node actionlint.ExprNode) bool) bool

Match reports whether any `${{ }}` expression in value holds a node the predicate accepts. A value that does not parse counts as a match, so the caller defers the error to the evaluation, which reports it against the real values.

Types

type EvaluateFunc

type EvaluateFunc func(input string, defaultStatusCheck exprparser.DefaultStatusCheck) (any, error)

EvaluateFunc evaluates the source of a single expression, without the `${{ }}` delimiters. It exists so a caller can wrap the interpreter, for example to log or to mask the result.

type Evaluator

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

Evaluator evaluates the expressions of a value against one interpreter.

func New

func New(evaluate EvaluateFunc) Evaluator

New returns an Evaluator that evaluates single expressions with the given function. Pass Interpreter.Evaluate for a plain one.

func (Evaluator) EvalBool

func (ee Evaluator) EvalBool(expr string, defaultStatusCheck exprparser.DefaultStatusCheck) (bool, error)

EvalBool evaluates a condition such as an `if:`, an expression even without `${{ }}`, while literal text around one makes the whole value a string.

func (Evaluator) EvaluateScalar

func (ee Evaluator) EvaluateScalar(in string) (any, error)

EvaluateScalar keeps the type of a lone expression, so `${{ fromJSON('[1,2]') }}` stays an array.

func (Evaluator) EvaluateYamlNode

func (ee Evaluator) EvaluateYamlNode(node *yaml.Node) error

EvaluateYamlNode evaluates the expressions of a YAML value in place.

func (Evaluator) Interpolate

func (ee Evaluator) Interpolate(in string) (string, error)

Interpolate evaluates every part on its own, so a malformed one cannot restructure its neighbours.

Jump to

Keyboard shortcuts

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