predicates

package
v1.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 12 Imported by: 98

Documentation

Overview

Package predicates implements predicate utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(scheme *runtime.Scheme, logger logr.Logger, predicates ...predicate.Funcs) predicate.Funcs

All returns a predicate that returns true only if all given predicates return true.

func Any

func Any(scheme *runtime.Scheme, logger logr.Logger, predicates ...predicate.Funcs) predicate.Funcs

Any returns a predicate that returns true only if any given predicate returns true.

func ClusterControlPlaneInitialized added in v1.1.4

func ClusterControlPlaneInitialized(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterControlPlaneInitialized returns a Predicate that returns true on Update events when ControlPlaneInitializedCondition on a Cluster changes to true. Example use:

err := controller.Watch(
    source.Kind(cache, &clusterv1.Cluster{}),
    handler.EnqueueRequestsFromMapFunc(clusterToMachines)
    predicates.ClusterControlPlaneInitialized(mgr.GetScheme(), r.Log),
)

func ClusterCreateInfraReady deprecated

func ClusterCreateInfraReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterCreateInfraReady returns a predicate that returns true for a create event when a cluster has Status.InfrastructureReady set as true it also returns true if the resource provided is not a Cluster to allow for use with controller-runtime NewControllerManagedBy.

Deprecated: This predicate is deprecated and will be removed in a future version. On creation of a cluster the status will always be empty. Because of that the predicate would never return true for InfrastructureReady.

func ClusterCreateNotPaused

func ClusterCreateNotPaused(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterCreateNotPaused returns a predicate that returns true for a create event when a cluster has Spec.Paused set as false it also returns true if the resource provided is not a Cluster to allow for use with controller-runtime NewControllerManagedBy.

func ClusterHasTopology added in v0.99.99

func ClusterHasTopology(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterHasTopology returns a Predicate that returns true when cluster.Spec.Topology is NOT nil and false otherwise.

func ClusterPausedTransitions added in v1.9.0

func ClusterPausedTransitions(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterPausedTransitions returns a predicate that returns true for an update event when a cluster has Spec.Paused changed.

func ClusterPausedTransitionsOrInfrastructureReady added in v1.9.0

func ClusterPausedTransitionsOrInfrastructureReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterPausedTransitionsOrInfrastructureReady returns a Predicate that returns true on Cluster Update events where either Cluster.Spec.Paused transitions or Cluster.Status.InfrastructureReady transitions to true. This implements a common requirement for some cluster-api and provider controllers (such as Machine Infrastructure controllers) to resume reconciliation when the Cluster gets paused or unpaused and when the infrastructure becomes ready. Example use:

err := controller.Watch(
    source.Kind(cache, &clusterv1.Cluster{}),
    handler.EnqueueRequestsFromMapFunc(clusterToMachines)
    predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), r.Log),
)

func ClusterUnpaused

func ClusterUnpaused(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterUnpaused returns a Predicate that returns true on Cluster creation events where Cluster.Spec.Paused is false and Update events when Cluster.Spec.Paused transitions to false. This implements a common requirement for many cluster-api and provider controllers (such as Cluster Infrastructure controllers) to resume reconciliation when the Cluster is unpaused. Example use:

err := controller.Watch(
    source.Kind(cache, &clusterv1.Cluster{}),
    handler.EnqueueRequestsFromMapFunc(clusterToMachines)
    predicates.ClusterUnpaused(mgr.GetScheme(), r.Log),
)

func ClusterUnpausedAndInfrastructureReady deprecated

func ClusterUnpausedAndInfrastructureReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterUnpausedAndInfrastructureReady returns a Predicate that returns true on Cluster creation events where both Cluster.Spec.Paused is false and Cluster.Status.InfrastructureReady is true and Update events when either Cluster.Spec.Paused transitions to false or Cluster.Status.InfrastructureReady transitions to true. This implements a common requirement for some cluster-api and provider controllers (such as Machine Infrastructure controllers) to resume reconciliation when the Cluster is unpaused and when the infrastructure becomes ready. Example use:

err := controller.Watch(
    source.Kind(cache, &clusterv1.Cluster{}),
    handler.EnqueueRequestsFromMapFunc(clusterToMachines)
    predicates.ClusterUnpausedAndInfrastructureReady(mgr.GetScheme(), r.Log),
)

Deprecated: This predicate is deprecated and will be removed in a future version, use ClusterPausedTransitionsOrInfrastructureReady instead.

func ClusterUpdateInfraReady

func ClusterUpdateInfraReady(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterUpdateInfraReady returns a predicate that returns true for an update event when a cluster has Status.InfrastructureReady changed from false to true it also returns true if the resource provided is not a Cluster to allow for use with controller-runtime NewControllerManagedBy.

func ClusterUpdateUnpaused

func ClusterUpdateUnpaused(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ClusterUpdateUnpaused returns a predicate that returns true for an update event when a cluster has Spec.Paused changed from true to false it also returns true if the resource provided is not a Cluster to allow for use with controller-runtime NewControllerManagedBy.

func ResourceHasFilterLabel added in v0.4.0

func ResourceHasFilterLabel(scheme *runtime.Scheme, logger logr.Logger, labelValue string) predicate.Funcs

ResourceHasFilterLabel returns a predicate that returns true only if the provided resource contains a label with the WatchLabel key and the configured label value exactly.

func ResourceIsNotExternallyManaged added in v0.4.0

func ResourceIsNotExternallyManaged(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ResourceIsNotExternallyManaged returns a predicate that returns true only if the resource does not contain the externally managed annotation. This implements a requirement for InfraCluster providers to be able to ignore externally managed cluster infrastructure.

func ResourceIsTopologyOwned added in v0.4.3

func ResourceIsTopologyOwned(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ResourceIsTopologyOwned returns a predicate that returns true only if the resource has the `topology.cluster.x-k8s.io/owned` label.

func ResourceNotPaused

func ResourceNotPaused(scheme *runtime.Scheme, logger logr.Logger) predicate.Funcs

ResourceNotPaused returns a Predicate that returns true only if the provided resource does not contain the paused annotation. This implements a common requirement for all cluster-api and provider controllers skip reconciliation when the paused annotation is present for a resource. Example use:

func (r *MyReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
	controller, err := ctrl.NewControllerManagedBy(mgr).
		For(&v1.MyType{}).
		WithOptions(options).
		WithEventFilter(util.ResourceNotPaused(mgr.GetScheme(), r.Log)).
		Build(r)
	return err
}

func ResourceNotPausedAndHasFilterLabel added in v0.4.0

func ResourceNotPausedAndHasFilterLabel(scheme *runtime.Scheme, logger logr.Logger, labelValue string) predicate.Funcs

ResourceNotPausedAndHasFilterLabel returns a predicate that returns true only if the ResourceNotPaused and ResourceHasFilterLabel predicates return true.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL