Documentation ¶
Overview ¶
TODO(nklaassen): evaluate the risks and utility of allowing traits to be used as regular expressions. The only thing blocking this today is that all trait values are lists and the regex must be a single value. It could be possible to write: `{{regexp.match(email.local(head(external.trait_name)))}}`
Index ¶
Constants ¶
const ( // EmailLocalFnName is a name for email.local function EmailLocalFnName = "email.local" // RegexpMatchFnName is a name for regexp.match function. RegexpMatchFnName = "regexp.match" // RegexpNotMatchFnName is a name for regexp.not_match function. RegexpNotMatchFnName = "regexp.not_match" // RegexpReplaceFnName is a name for regexp.replace function. RegexpReplaceFnName = "regexp.replace" )
Variables ¶
This section is empty.
Functions ¶
func EmailLocal ¶
EmailLocal returns a new list which is a result of getting the local part of each email from the input list.
Types ¶
type MatchExpression ¶
type MatchExpression struct {
// contains filtered or unexported fields
}
MatchExpression is a match expression.
func NewMatcher ¶
func NewMatcher(value string) (*MatchExpression, error)
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.
func (*MatchExpression) Match ¶
func (e *MatchExpression) Match(in string) bool
type Matcher ¶
Matcher matches strings against some internal criteria (e.g. a regexp)
func NewAnyMatcher ¶
NewAnyMatcher returns a matcher function based on incoming values
type TraitsTemplateExpression ¶
type TraitsTemplateExpression struct {
// contains filtered or unexported fields
}
TraitsTemplateExpression can interpolate user trait values into a string template to produce some values.
func NewTraitsTemplateExpression ¶
func NewTraitsTemplateExpression(value string) (*TraitsTemplateExpression, error)
NewTraitsTemplateExpression 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 user traits.
func (*TraitsTemplateExpression) Interpolate ¶
func (e *TraitsTemplateExpression) Interpolate(varValidation func(namespace, name string) error, traits map[string][]string) ([]string, error)
Interpolate interpolates the variable adding prefix and suffix if present. The returned error is trace.NotFound in case the expression contains a variable and this variable is not found on any trait, nil in case of success, and BadParameter otherwise.