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 ¶
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 ¶
EvaluateScalar keeps the type of a lone expression, so `${{ fromJSON('[1,2]') }}` stays an array.
func (Evaluator) EvaluateYamlNode ¶
EvaluateYamlNode evaluates the expressions of a YAML value in place.