Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNestedExpression = errors.New("nested expressions are not allowed unless inside string literals")
Allow nested expressions, but only if they are escaped with quotes ${outer("${inner}")} is allowed, but ${outer(${inner})} is not
Functions ¶
func ExtractExpressions ¶ added in v0.2.0
ExtractExpressions extracts all non-nested CEL expressions from a string. It returns an error if it encounters a nested expression.
func ParseConditionExpressions ¶
func ParseConditionExpressions(conditions []string) ([]*krocel.Expression, error)
ParseConditionExpressions parses resource condition expressions (readyWhen, includeWhen). These must be standalone expressions (${...}). Returns Expression objects with Original set; References and Program are populated later by builder.
func ParseSchemalessResource ¶
func ParseSchemalessResource(resource map[string]interface{}) ([]variable.FieldDescriptor, []string, error)
ParseSchemalessResource extracts CEL expressions without a schema, this is useful when the schema is not available. e.g RGI statuses
Types ¶
type Parser ¶ added in v0.2.0
type Parser struct {
// contains filtered or unexported fields
}
Parser extracts CEL expressions from resources using OpenAPI schemas. When a SchemaLookup is provided, field lookups go through it to produce pointer-stable results suitable for downstream caching.
func New ¶ added in v0.2.0
func New(schemas SchemaLookup) *Parser
New creates a Parser with the given schema lookup.
func (*Parser) ParseResource ¶ added in v0.2.0
func (p *Parser) ParseResource(resource map[string]interface{}, resourceSchema *spec.Schema) ([]variable.FieldDescriptor, error)
ParseResource extracts CEL expressions from a resource based on the schema. The resource is expected to be a map[string]interface{}.
Note that this function will also validate the resource against the schema and return an error if the resource does not match the schema. When CEL expressions are found, they are extracted and returned with the schema of the field. The caller is responsible for converting schemas to CEL types with appropriate type naming.