expreval

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package expreval shares workflow expression splitting, interpolation and truthiness between Gitea and the runner.

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 Literal added in v1.3.0

func Literal(value string) (string, bool)

Literal returns the text of a value that is plain text or a lone string literal expression.

func Match

func Match(value string, match func(node exprparser.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.

func ReadsContext added in v1.0.0

func ReadsContext(value, contextName string) bool

ReadsContext reports whether value reads the named context, without exposing the AST.

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 reads bare expressions and interpolated strings as conditions, like GitHub's ConvertToIfCondition. Blank conditions evaluate the default status check alone.

func (Evaluator) EvaluateCallerSecrets added in v1.1.0

func (ee Evaluator) EvaluateCallerSecrets(mapping map[string]string) (map[string]string, error)

EvaluateCallerSecrets interpolates a caller's `secrets` mapping, which GitHub lets read the caller's contexts including secrets.

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) EvaluateWorkflowCallOutputs added in v1.1.0

func (ee Evaluator) EvaluateWorkflowCallOutputs(config *model.WorkflowCall) (map[string]string, error)

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.

func (Evaluator) ResolveWorkflowCallInputs added in v1.1.0

func (ee Evaluator) ResolveWorkflowCallInputs(config *model.WorkflowCall, with map[string]any) (map[string]any, error)

ResolveWorkflowCallInputs types `with` like GitHub, returning defaulted inputs alongside the joined validation errors.

Jump to

Keyboard shortcuts

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