cel package - github.com/fluxcd/pkg/runtime/cel - Go Packages
cel provides utilities for evaluating Common Expression Language (CEL) expressions.
- func NewStatusReader(healthchecks []kustomize.CustomHealthCheck) (func(meta.RESTMapper) engine.StatusReader, error)
- type Expression
- func (e *Expression) Evaluate(ctx context.Context, data map[string]any) (any, error)
- func (e *Expression) EvaluateBoolean(ctx context.Context, data map[string]any) (bool, error)
- func (e *Expression) EvaluateString(ctx context.Context, data map[string]any) (string, error)
- func (e *Expression) EvaluateStringSlice(ctx context.Context, data map[string]any) ([]string, error)
- func (e *Expression) String() string
- type Option
- type StatusEvaluator
- type StatusReader
- func (g *StatusReader) ReadStatus(ctx context.Context, reader engine.ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error)
- func (g *StatusReader) ReadStatusForObject(ctx context.Context, reader engine.ClusterReader, ...) (*event.ResourceStatus, error)
- func (g *StatusReader) Supports(gk schema.GroupKind) bool
This section is empty.
This section is empty.
NewStatusReader returns a new StatusReader for the given GroupKind and healthcheck expressions.
type Expression struct {
}
Expression represents a parsed CEL expression.
NewExpression parses the given CEL expression and returns a new Expression.
Evaluate evaluates the expression with the given data and returns the result as any.
EvaluateBoolean evaluates the expression with the given data and returns the result as a boolean.
EvaluateString evaluates the expression with the given data and returns the result as a string.
EvaluateStringSlice evaluates the expression with the given data and returns the result as []string.
String returns the original CEL expression string.
type Option func(*options)
Option is a function that configures the CEL expression.
func WithCompile() Option
WithCompile specifies that the expression should be compiled, which provides stricter checks at parse time, before evaluation.
WithOutputType specifies the expected output type of the expression.
type StatusEvaluator struct {
}
StatusEvaluator evaluates the health status of a custom resource object.
NewStatusEvaluator returns a new StatusEvaluator.
Evaluate evaluates the health status of a custom resource object according to the rules defined in RFC 0009:
First we check if the object has the field status.observedGeneration. If it does, and the value is different from metadata.generation, we return the status InProgress.
Then we evaluate the healthcheck expressions in the following order: - InProgress: if true, return status InProgress - Failed: if true, return status Failed - Current: if true, return status Current
If none of the expressions are true, we return status InProgress.
type StatusReader struct {
}
StatusReader implements the engine.StatusReader interface for a specific GroupKind and set of healthcheck expressions.
ReadStatus reads the status of the resource with the given metadata.
ReadStatusForObject reads the status of the given resource.
Supports returns true if the StatusReader supports the given GroupKind.