Documentation
¶
Overview ¶
cel provides utilities for evaluating Common Expression Language (CEL) expressions.
Index ¶
- func NewStatusReader(ctx context.Context, mapper meta.RESTMapper, gk schema.GroupKind, ...) engine.StatusReader
- func PollerWithCustomHealthChecks(ctx context.Context, healthchecks []kustomize.CustomHealthCheck) ([]func(meta.RESTMapper) engine.StatusReader, error)
- type Expression
- 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStatusReader ¶
func NewStatusReader(ctx context.Context, mapper meta.RESTMapper, gk schema.GroupKind, se *StatusEvaluator) engine.StatusReader
NewStatusReader returns a new StatusReader for the given GroupKind and healthcheck expressions. The context is used to control the execution of the underlying operations performed by the the reader.
func PollerWithCustomHealthChecks ¶
func PollerWithCustomHealthChecks(ctx context.Context, healthchecks []kustomize.CustomHealthCheck) ([]func(meta.RESTMapper) engine.StatusReader, error)
PollerWithCustomHealthChecks creates a list of constructors for custom status readers from a list of custom health checks. If there are multiple healthchecks defined for the same GroupKind, only the first one is used. The context is used to control the execution of the underlying status readers.
Types ¶
type Expression ¶
type Expression struct {
// contains filtered or unexported fields
}
Expression represents a parsed CEL expression.
func NewExpression ¶
func NewExpression(expr string, opts ...Option) (*Expression, error)
NewExpression parses the given CEL expression and returns a new Expression.
func (*Expression) EvaluateBoolean ¶
EvaluateBoolean evaluates the expression with the given data and returns the result as a boolean.
func (*Expression) EvaluateString ¶ added in v0.55.0
EvaluateString evaluates the expression with the given data and returns the result as a string.
type Option ¶
type Option func(*options)
Option is a function that configures the CEL expression.
func WithCompile ¶
func WithCompile() Option
WithCompile specifies that the expression should be compiled, which provides stricter checks at parse time, before evaluation.
func WithOutputType ¶
WithOutputType specifies the expected output type of the expression.
func WithStructVariables ¶
WithStructVariables declares variables of type google.protobuf.Struct.
type StatusEvaluator ¶
type StatusEvaluator struct {
// contains filtered or unexported fields
}
StatusEvaluator evaluates the health status of a custom resource object.
func NewStatusEvaluator ¶
func NewStatusEvaluator(exprs *kustomize.HealthCheckExpressions) (*StatusEvaluator, error)
NewStatusEvaluator returns a new StatusEvaluator.
func (*StatusEvaluator) Evaluate ¶
func (s *StatusEvaluator) Evaluate(ctx context.Context, u *unstructured.Unstructured) (*status.Result, error)
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 ¶
type StatusReader struct {
// contains filtered or unexported fields
}
StatusReader implements the engine.StatusReader interface for a specific GroupKind and set of healthcheck expressions.
func (*StatusReader) ReadStatus ¶
func (g *StatusReader) ReadStatus(ctx context.Context, reader engine.ClusterReader, resource object.ObjMetadata) (*event.ResourceStatus, error)
ReadStatus reads the status of the resource with the given metadata.
func (*StatusReader) ReadStatusForObject ¶
func (g *StatusReader) ReadStatusForObject(ctx context.Context, reader engine.ClusterReader, resource *unstructured.Unstructured) (*event.ResourceStatus, error)
ReadStatusForObject reads the status of the given resource.