Documentation ¶
Index ¶
- Constants
- Variables
- func AllowedOutputTypes() []*cel.Type
- func CheckOutputTypeAllowed(ast *cel.Ast, allowed ...*cel.Type) error
- func NewEnv(resource reflect.Type) (*cel.Env, error)
- func ParseStructTag(field reflect.StructField) string
- func RegisterEvaluator(e ExpressionEvaluator)
- type CompilationResult
- type EnvCache
- type ExpressionEvaluator
- type ExpressionEvaluatorOption
- type ExpressionResult
- type ProgramCache
- type ProgramCacher
- type UnCache
Constants ¶
const ( SelfIdent = "self" SecretIdent = "secret" )
Variables ¶
var ( StringType = cel.StringType MapType = cel.MapType(cel.StringType, cel.StringType) )
Functions ¶
func AllowedOutputTypes ¶
AllowedOutputTypes defines the set of allowed CEL expression output types supported by ASO. Any CEL expression whose result is a type other than one of these will be rejected.
func NewEnv ¶
NewEnv returns a new cel.Env accepting two parameters:
self: The resource itself. The resulting Env contains knowledge of all types referenced by self, meaning CEL expressions involving self must all pass the type-checker.
secret: Optional (may be nil/empty), a map[string]string containing secrets retrieved from Azure. The keys of the secret are the same as the keys in the operatorSpec.secrets structure.
func ParseStructTag ¶
func ParseStructTag(field reflect.StructField) string
func RegisterEvaluator ¶
func RegisterEvaluator(e ExpressionEvaluator)
TODO: We could put this instead in genruntime if we thought it made more sense to keep the "static value for use by webhooks" TODO: there. RegisterEvaluator registers an evaluator as the default expression evaluator.
Types ¶
type CompilationResult ¶
type EnvCache ¶
type EnvCache struct {
// contains filtered or unexported fields
}
EnvCache caches cel.Env's for a fixed duration.
type ExpressionEvaluator ¶
type ExpressionEvaluator interface { CompileAndRun(expression string, self any, secret map[string]string) (*ExpressionResult, error) Check(expression string, self any) (*cel.Type, error) FindSecretUsage(expression string, self any) (set.Set[string], error) Start() Stop() }
ExpressionEvaluator defines an interface for evaluating expressions based on self (the resource) and an optional secret parameter (containing the secrets)
func Evaluator ¶
func Evaluator() ExpressionEvaluator
Evaluator returns the default expression evaluator
func NewExpressionEvaluator ¶
func NewExpressionEvaluator( opts ...ExpressionEvaluatorOption, ) (ExpressionEvaluator, error)
type ExpressionEvaluatorOption ¶
type ExpressionEvaluatorOption func(e *expressionEvaluator) (*expressionEvaluator, error)
func Cache ¶
func Cache(cache ProgramCacher) ExpressionEvaluatorOption
Cache configures the program cache for the expression evaluator. The program cache is used to avoid re-compiling expressions or creating cel.Envs more than necessary.
func Metrics ¶
func Metrics(metrics asometrics.CEL) ExpressionEvaluatorOption
Metrics configures CEL prometheus metrics
type ExpressionResult ¶
type ProgramCache ¶
type ProgramCache struct {
// contains filtered or unexported fields
}
func NewProgramCache ¶
func NewProgramCache( envCache *EnvCache, metrics asometrics.CEL, log logr.Logger, compile func(env *cel.Env, expression string) (*CompilationResult, error), ) *ProgramCache
NewProgramCache starts the program cache
func (*ProgramCache) Get ¶
func (c *ProgramCache) Get(resource reflect.Type, expression string) (*CompilationResult, error)
func (*ProgramCache) Start ¶
func (c *ProgramCache) Start()
func (*ProgramCache) Stop ¶
func (c *ProgramCache) Stop()
type ProgramCacher ¶
type ProgramCacher interface { Start() Stop() Get(resource reflect.Type, expression string) (*CompilationResult, error) }