Documentation
¶
Overview ¶
Package parser provides helpers to locate and validate CEL expressions embedded in strings.
CEL expressions are delimited by the literal sequence `${` and a matching `}`. The parser recognizes string literals and escape sequences and enforces the rule that nested expressions are not allowed unless they appear inside a string literal. For example:
- `${outer("${inner}")}` is allowed
- `${outer(${inner})}` is not allowed and will cause ErrNestedExpression
The primary behaviors implemented in this package:
- ParseSchemaless: returns all CEL expressions found in a schemaless map[string]any structure
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNestedExpression = errors.New("nested expressions are not allowed unless inside string literals")
ErrNestedExpression is returned when an expression contains another unescaped expression. Nested expressions are only allowed when the inner expression appears inside a string literal, for example:
${outer("${inner}")} // allowed
${outer(${inner})} // not allowed
Functions ¶
func ExtractExpressions ¶
ExtractExpressions extracts all non-nested CEL expressions from a string. It returns an error if it encounters an illegal nested expression.
func IsStandaloneExpression ¶
IsStandaloneExpression checks if input is exactly one full expression.
func ParseSchemaless ¶
func ParseSchemaless(resource map[string]any) ([]variable.FieldDescriptor, error)
ParseSchemaless extracts CEL expressions without a schema
Types ¶
This section is empty.