Documentation
¶
Overview ¶
Package expreval shares workflow expression splitting, interpolation and truthiness between Gitea and the runner.
Index ¶
- func CallsFunction(value string, names ...string) bool
- func Literal(value string) (string, bool)
- func Match(value string, match func(node exprparser.ExprNode) bool) bool
- func ReadsContext(value, contextName string) bool
- type EvaluateFunc
- type Evaluator
- func (ee Evaluator) EvalBool(expr string, defaultStatusCheck exprparser.DefaultStatusCheck) (bool, error)
- func (ee Evaluator) EvaluateCallerSecrets(mapping map[string]string) (map[string]string, error)
- func (ee Evaluator) EvaluateScalar(in string) (any, error)
- func (ee Evaluator) EvaluateWorkflowCallOutputs(config *model.WorkflowCall) (map[string]string, error)
- func (ee Evaluator) EvaluateYamlNode(node *yaml.Node) error
- func (ee Evaluator) Interpolate(in string) (string, error)
- func (ee Evaluator) ResolveWorkflowCallInputs(config *model.WorkflowCall, with map[string]any) (map[string]any, error)
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 Literal ¶ added in v1.3.0
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
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
EvaluateCallerSecrets interpolates a caller's `secrets` mapping, which GitHub lets read the caller's contexts including secrets.
func (Evaluator) EvaluateScalar ¶
EvaluateScalar keeps the type of a lone expression, so `${{ fromJSON('[1,2]') }}` stays an array.
func (Evaluator) EvaluateWorkflowCallOutputs ¶ added in v1.1.0
func (Evaluator) EvaluateYamlNode ¶
EvaluateYamlNode evaluates the expressions of a YAML value in place.
func (Evaluator) Interpolate ¶
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.