Documentation ¶
Overview ¶
TODO(awly): combine Expression and Matcher. It should be possible to write: `{{regexp.match(email.local(external.trait_name))}}`
Index ¶
Constants ¶
const ( // LiteralNamespace is a namespace for Expressions that always return // static literal values. LiteralNamespace = "literal" // EmailNamespace is a function namespace for email functions EmailNamespace = "email" // EmailLocalFnName is a name for email.local function EmailLocalFnName = "local" // RegexpNamespace is a function namespace for regexp functions. RegexpNamespace = "regexp" // RegexpMatchFnName is a name for regexp.match function. RegexpMatchFnName = "match" // RegexpNotMatchFnName is a name for regexp.not_match function. RegexpNotMatchFnName = "not_match" // RegexpReplaceFnName is a name for regexp.replace function. RegexpReplaceFnName = "replace" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression is an expression template that can interpolate to some variables
func NewExpression ¶
func NewExpression(variable string) (*Expression, error)
NewExpression parses expressions like {{external.foo}} or {{internal.bar}}, or a literal value like "prod". Call Interpolate on the returned Expression to get the final value based on traits or other dynamic values.
func (*Expression) Interpolate ¶
func (p *Expression) Interpolate(traits map[string][]string) ([]string, error)
Interpolate interpolates the variable adding prefix and suffix if present, returns trace.NotFound in case if the trait is not found, nil in case of success and BadParameter error otherwise
func (*Expression) Namespace ¶
func (p *Expression) Namespace() string
Namespace returns a variable namespace, e.g. external or internal
type Matcher ¶
Matcher matches strings against some internal criteria (e.g. a regexp)
func NewAnyMatcher ¶
NewAnyMatcher returns a matcher function based on incoming values
func NewMatcher ¶
NewMatcher parses a matcher expression. Currently supported expressions: - string literal: `foo` - wildcard expression: `*` or `foo*bar` - regexp expression: `^foo$` - regexp function calls:
- positive match: `{{regexp.match("foo.*")}}`
- negative match: `{{regexp.not_match("foo.*")}}`
These expressions do not support variable interpolation (e.g. `{{internal.logins}}`), like Expression does.