Documentation
¶
Overview ¶
Package expr compiles and evaluates the predicates of intent and workflow manifests: CEL expressions (cel-go) over typed facts, checked at load.
Index ¶
- Variables
- func Allowed(p workflow.Predicate, field string) ([]string, bool)
- func Closest(s string, options []string) string
- func CompileWorkflow(src string, env Env) (workflow.Predicate, error)
- func DidYouMean(s string, options []string) string
- func Pinned(p workflow.Predicate, field string) []string
- func ReadsNow(p workflow.Predicate) bool
- func Requires(p workflow.Predicate, field, value string) bool
- func Suggest(s string, options []string) string
- type Env
- type Error
- type Facts
- type Program
- type Type
Constants ¶
This section is empty.
Variables ¶
var Renamed = func(string) string { return "" }
Renamed is the name that replaced s, a name the language no longer has; "" when s was never renamed. The builtin package sets it from its table.
Functions ¶
func Allowed ¶ added in v0.5.0
Allowed are the values every match of p takes field among, as its top-level conjunction's field == "literal" and field in ["literal", ...] terms allow them; false when no such term bounds field.
func Closest ¶ added in v0.2.0
Closest is the option a typo of s plausibly meant, "" when none is that close: the same word in another case, or one at most max(1, len(s)/4) edits away, a swap of two neighbors counting as one. A tie is no suggestion, since either guess may be wrong.
func CompileWorkflow ¶
CompileWorkflow compiles a workflow's `when` over env (one unit slot, trigger.* and config.*) plus now, the evaluation's time.
func DidYouMean ¶ added in v0.2.0
DidYouMean is "; did you mean \"x\"?" for Suggest's x, "" when none.
func Pinned ¶ added in v0.3.0
Pinned are the literals p's top-level conjunction pins field to, as Requires reads them.
func ReadsNow ¶ added in v0.3.0
ReadsNow says whether p, a CompileWorkflow predicate, reads now, so its value can change as time passes with no fact changing.
Types ¶
type Env ¶
func (Env) Enum ¶ added in v0.2.0
Enum is the closed values of name, sorted; nil when it takes any value.
func (Env) SetEnum ¶ added in v0.2.0
SetEnum declares the closed values of the string fact name: a predicate that compares it with a literal outside them does not compile.
func (Env) SetUntrusted ¶ added in v0.3.0
SetUntrusted marks the fact name as one an agent or a third party may set, which no releasing approval rule reads.
type Error ¶
type Facts ¶
Facts resolves a dotted field; the value's Go type matches the Env (bool, int, string, []string, time.Duration, time.Time).
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
func Compile ¶
Compile type-checks src against env; it returns an *Error on failure, and an empty or blank src is an error.
func CompileString ¶ added in v0.3.0
CompileString type-checks src, an expression whose value is a string, against env, as Compile does a predicate; Text evaluates it.
func (*Program) Eval ¶
Eval evaluates the predicate; a nil fact reads as its type's zero value and a runtime error, such as a fact of another Go type, reads as false.
func (*Program) Holds ¶ added in v0.4.0
Holds evaluates the predicate over facts, a fact facts lacks reading as its type's zero value; a runtime error, such as a fact of another Go type, is the error.