Documentation
¶
Overview ¶
Package predicate provides serializable predicate support for filtering Kubernetes resources in Δ-controller source specifications.
Predicates allow controllers to selectively watch and process resource changes that match specific criteria, improving performance and reducing unnecessary reconciliation work.
Supported predicate types:
- GenerationChanged: Triggers on metadata.generation changes.
- ResourceVersionChanged: Triggers on any resource changes.
- LabelChanged: Triggers on label modifications.
- AnnotationChanged: Triggers on annotation modifications.
Boolean combinators allow complex predicate logic:
- And: All predicates must be true.
- Or: Any predicate must be true.
- Not: Inverts predicate result.
Predicates are JSON-serializable and can be embedded in Operator specifications to control source resource filtering behavior.
Example usage:
predicate := Predicate{
BoolPredicate: BoolPredicate{
"And": []Predicate{
{BasicPredicate: &BasicPredicate("GenerationChanged")},
{BasicPredicate: &BasicPredicate("LabelChanged")},
},
},
}
Index ¶
- func FromLabelSelector(labelSelector metav1.LabelSelector) (predicate.TypedPredicate[client.Object], error)
- func FromNamespace(namespace string) predicate.TypedPredicate[client.Object]
- func FromPredicate(predicate Predicate) (predicate.TypedPredicate[client.Object], error)
- type BasicPredicate
- type BoolPredicate
- type Interface
- type Predicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromLabelSelector ¶
func FromLabelSelector(labelSelector metav1.LabelSelector) (predicate.TypedPredicate[client.Object], error)
FromLabelSelector creates converts a seriaized label selector into a native controller runtime label selector predicate.
func FromNamespace ¶
func FromNamespace(namespace string) predicate.TypedPredicate[client.Object]
FromNamespace creates a namespace selector predicate from a namespace.
func FromPredicate ¶
FromPredicate converts a serialized Predicate into a native controller runtime predicate.
Types ¶
type BasicPredicate ¶
type BasicPredicate string
BasicPredicate represents an elemental predicate, namely one of "GenerationChanged", "ResourceVersionChanged", "LabelChanged" or "AnnotationChanged".
func (*BasicPredicate) ToPredicate ¶
func (pw *BasicPredicate) ToPredicate() (predicate.TypedPredicate[client.Object], error)
ToPredicate implements ToPredicate() for basic predicates.
type BoolPredicate ¶
BoolPredicate is a complex predicate composed of basic predicates and other bool predicates.
func (*BoolPredicate) ToPredicate ¶
func (cp *BoolPredicate) ToPredicate() (predicate.TypedPredicate[client.Object], error)
ToPredicate implements ToPredicate() for bool predicates.
type Interface ¶
type Interface interface {
// ToPredicate converts a serialized predicate into a native controller runtime predicate.
ToPredicate() (predicate.TypedPredicate[client.Object], error)
}
Interface is the general interface for predicates.
type Predicate ¶
type Predicate struct {
*BasicPredicate `json:",inline"`
*BoolPredicate `json:",inline"`
}
Predicate is the top level representation of a predicate.
func (Predicate) DeepCopyInto ¶
DeepCopyInto copies a predicate into target predicate.
func (Predicate) MarshalJSON ¶
MarshalJSON encodes a predicate in JSON format.
func (*Predicate) ToPredicate ¶
ToPredicate converts a serialized predicate into a native controller runtime predicate.
func (*Predicate) UnmarshalJSON ¶
UnmarshalJSON decodes a predicate from JSON format.