From 97df6f8b52186f11aec6d70fc9cd6896ddde1d75 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Wed, 25 Jun 2025 14:45:25 +0200 Subject: [PATCH] add For method in controller --- .../atlasthirdpartyintegrations/setup.go | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/internal/controller/atlasthirdpartyintegrations/setup.go b/internal/controller/atlasthirdpartyintegrations/setup.go index 025d141d49..2cda1fe041 100644 --- a/internal/controller/atlasthirdpartyintegrations/setup.go +++ b/internal/controller/atlasthirdpartyintegrations/setup.go @@ -78,23 +78,20 @@ func NewAtlasThirdPartyIntegrationsReconciler( // For prepares the controller for its target Custom Resource; AtlasThirdPartyIntegration func (r *AtlasThirdPartyIntegrationHandler) For() (client.Object, builder.Predicates) { - return &akov2.AtlasThirdPartyIntegration{}, builder.WithPredicates(predicate.GenerationChangedPredicate{}) + obj := &akov2.AtlasThirdPartyIntegration{} + return obj, ctrlrtbuilder.WithPredicates( + predicate.Or( + mckpredicate.AnnotationChanged("mongodb.com/reapply-period"), + predicate.GenerationChangedPredicate{}, + ), + mckpredicate.IgnoreDeletedPredicate[client.Object](), + ) } func (h *AtlasThirdPartyIntegrationHandler) SetupWithManager(mgr ctrl.Manager, rec reconcile.Reconciler, defaultOptions controller.Options) error { h.Client = mgr.GetClient() - obj := &akov2.AtlasThirdPartyIntegration{} return controllerruntime.NewControllerManagedBy(mgr). - For( - obj, - ctrlrtbuilder.WithPredicates( - predicate.Or( - mckpredicate.AnnotationChanged("mongodb.com/reapply-period"), - predicate.GenerationChangedPredicate{}, - ), - mckpredicate.IgnoreDeletedPredicate[client.Object](), - ), - ). + For(h.For()). Watches( &akov2.AtlasProject{}, handler.EnqueueRequestsFromMapFunc(h.integrationForProjectMapFunc()),