From 777a72783f584c4a51f68cb529d62f482146a8a5 Mon Sep 17 00:00:00 2001 From: Michael Montgomery Date: Wed, 1 Dec 2021 11:42:48 -0600 Subject: [PATCH] Cleanup predicate calling code per @barkbay suggestion. Fix test --- cmd/manager/main.go | 5 ++- pkg/controller/agent/controller.go | 2 +- pkg/controller/apmserver/controller.go | 2 +- .../controller/agent_fleetserver.go | 2 +- .../association/controller/agent_kibana.go | 2 +- .../association/controller/apm_es.go | 2 +- .../association/controller/apm_kibana.go | 2 +- .../association/controller/beat_es.go | 2 +- .../association/controller/beat_kibana.go | 2 +- .../association/controller/ent_es.go | 2 +- .../association/controller/es_monitoring.go | 2 +- .../association/controller/kb_monitoring.go | 2 +- .../association/controller/kibana_ent.go | 2 +- .../association/controller/kibana_es.go | 2 +- .../association/controller/maps_es.go | 2 +- pkg/controller/autoscaling/elasticsearch.go | 2 +- pkg/controller/beat/controller.go | 2 +- .../common/predicates/predicate_test.go | 2 +- .../common/predicates/predicates.go | 44 +++++++++---------- .../elasticsearch/elasticsearch_controller.go | 2 +- .../enterprisesearch_controller.go | 2 +- pkg/controller/kibana/controller.go | 2 +- pkg/controller/license/license_controller.go | 2 +- .../license_controller_integration_test.go | 2 +- pkg/controller/maps/controller.go | 2 +- pkg/controller/remoteca/controller.go | 2 +- 26 files changed, 48 insertions(+), 49 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 5ae58557f60..538978817fd 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -462,6 +462,9 @@ func startOperator(ctx context.Context) error { // configure the manager cache based on the number of managed namespaces managedNamespaces := viper.GetStringSlice(operator.NamespacesFlag) + // initialize the managed namespace predicate to ignore events outside of the namespaces the operator is concerned with + predicates.ManagedNamespacePredicate = predicates.NewManagedNamespacesPredicate(managedNamespaces) + switch { case len(managedNamespaces) == 0: log.Info("Operator configured to manage all namespaces") @@ -789,7 +792,7 @@ func setupWebhook(mgr manager.Manager, params operator.Parameters, clientset kub os.Exit(1) } - if err := webhook.Add(mgr, webhookParams, clientset, wh, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)); err != nil { + if err := webhook.Add(mgr, webhookParams, clientset, wh, predicates.ManagedNamespacePredicate); err != nil { log.Error(err, "unable to create controller", "controller", webhook.ControllerName) os.Exit(1) } diff --git a/pkg/controller/agent/controller.go b/pkg/controller/agent/controller.go index b9b3550c88e..481d7caf165 100644 --- a/pkg/controller/agent/controller.go +++ b/pkg/controller/agent/controller.go @@ -45,7 +45,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, r, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, r, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler. diff --git a/pkg/controller/apmserver/controller.go b/pkg/controller/apmserver/controller.go index 4d44a6f89f1..ad9d0763975 100644 --- a/pkg/controller/apmserver/controller.go +++ b/pkg/controller/apmserver/controller.go @@ -84,7 +84,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, reconciler, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, reconciler, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/association/controller/agent_fleetserver.go b/pkg/controller/association/controller/agent_fleetserver.go index 60e7850df09..ecf7a94b569 100644 --- a/pkg/controller/association/controller/agent_fleetserver.go +++ b/pkg/controller/association/controller/agent_fleetserver.go @@ -41,7 +41,7 @@ func AddAgentFleetServer(mgr manager.Manager, accessReviewer rbac.AccessReviewer AssociationConfAnnotationNameBase: commonv1.FleetServerConfigAnnotationNameBase, AssociationResourceNameLabelName: agent.NameLabelName, AssociationResourceNamespaceLabelName: agent.NamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: nil, }) diff --git a/pkg/controller/association/controller/agent_kibana.go b/pkg/controller/association/controller/agent_kibana.go index d89ad353581..319f75a6530 100644 --- a/pkg/controller/association/controller/agent_kibana.go +++ b/pkg/controller/association/controller/agent_kibana.go @@ -39,7 +39,7 @@ func AddAgentKibana(mgr manager.Manager, accessReviewer rbac.AccessReviewer, par AssociationConfAnnotationNameBase: commonv1.KibanaConfigAnnotationNameBase, AssociationResourceNameLabelName: kibana.KibanaNameLabelName, AssociationResourceNamespaceLabelName: kibana.KibanaNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: getElasticsearchFromKibana, diff --git a/pkg/controller/association/controller/apm_es.go b/pkg/controller/association/controller/apm_es.go index 1feb95026f9..0bbe90e239d 100644 --- a/pkg/controller/association/controller/apm_es.go +++ b/pkg/controller/association/controller/apm_es.go @@ -57,7 +57,7 @@ func AddApmES(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params op AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/apm_kibana.go b/pkg/controller/association/controller/apm_kibana.go index 092797cc9c3..d8c9c8ca66b 100644 --- a/pkg/controller/association/controller/apm_kibana.go +++ b/pkg/controller/association/controller/apm_kibana.go @@ -44,7 +44,7 @@ func AddApmKibana(mgr manager.Manager, accessReviewer rbac.AccessReviewer, param AssociationConfAnnotationNameBase: commonv1.KibanaConfigAnnotationNameBase, AssociationResourceNameLabelName: kibana.KibanaNameLabelName, AssociationResourceNamespaceLabelName: kibana.KibanaNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: getElasticsearchFromKibana, diff --git a/pkg/controller/association/controller/beat_es.go b/pkg/controller/association/controller/beat_es.go index 750f8b42cfc..eb6d6f8c2bc 100644 --- a/pkg/controller/association/controller/beat_es.go +++ b/pkg/controller/association/controller/beat_es.go @@ -58,7 +58,7 @@ func AddBeatES(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params o AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/beat_kibana.go b/pkg/controller/association/controller/beat_kibana.go index 69574e8ec80..e485d0b7269 100644 --- a/pkg/controller/association/controller/beat_kibana.go +++ b/pkg/controller/association/controller/beat_kibana.go @@ -45,7 +45,7 @@ func AddBeatKibana(mgr manager.Manager, accessReviewer rbac.AccessReviewer, para AssociationConfAnnotationNameBase: commonv1.KibanaConfigAnnotationNameBase, AssociationResourceNameLabelName: kibana.KibanaNameLabelName, AssociationResourceNamespaceLabelName: kibana.KibanaNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: getElasticsearchFromKibana, diff --git a/pkg/controller/association/controller/ent_es.go b/pkg/controller/association/controller/ent_es.go index f9b68e47bb5..3c6aadc4354 100644 --- a/pkg/controller/association/controller/ent_es.go +++ b/pkg/controller/association/controller/ent_es.go @@ -53,7 +53,7 @@ func AddEntES(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params op AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/es_monitoring.go b/pkg/controller/association/controller/es_monitoring.go index ca517c71fbb..27c3edcafa1 100644 --- a/pkg/controller/association/controller/es_monitoring.go +++ b/pkg/controller/association/controller/es_monitoring.go @@ -59,7 +59,7 @@ func esMonitoringAssociationInfo(params operator.Parameters) association.Associa AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/kb_monitoring.go b/pkg/controller/association/controller/kb_monitoring.go index d561e74de0f..e8e420e7c7f 100644 --- a/pkg/controller/association/controller/kb_monitoring.go +++ b/pkg/controller/association/controller/kb_monitoring.go @@ -44,7 +44,7 @@ func AddKbMonitoring(mgr manager.Manager, accessReviewer rbac.AccessReviewer, pa AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/kibana_ent.go b/pkg/controller/association/controller/kibana_ent.go index fa43e43abfb..b4b4e52ae06 100644 --- a/pkg/controller/association/controller/kibana_ent.go +++ b/pkg/controller/association/controller/kibana_ent.go @@ -42,7 +42,7 @@ func AddKibanaEnt(mgr manager.Manager, accessReviewer rbac.AccessReviewer, param AssociationConfAnnotationNameBase: commonv1.EntConfigAnnotationNameBase, AssociationResourceNameLabelName: entctl.EnterpriseSearchNameLabelName, AssociationResourceNamespaceLabelName: entctl.EnterpriseSearchNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: nil, // no dedicated ES user required for Kibana->Ent connection }) } diff --git a/pkg/controller/association/controller/kibana_es.go b/pkg/controller/association/controller/kibana_es.go index 769f201d1bd..b9d9fe7fbdc 100644 --- a/pkg/controller/association/controller/kibana_es.go +++ b/pkg/controller/association/controller/kibana_es.go @@ -57,7 +57,7 @@ func AddKibanaES(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/association/controller/maps_es.go b/pkg/controller/association/controller/maps_es.go index 73db2627d21..5ffa9d2a59b 100644 --- a/pkg/controller/association/controller/maps_es.go +++ b/pkg/controller/association/controller/maps_es.go @@ -56,7 +56,7 @@ func AddMapsES(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params o AssociationConfAnnotationNameBase: commonv1.ElasticsearchConfigAnnotationNameBase, AssociationResourceNameLabelName: eslabel.ClusterNameLabelName, AssociationResourceNamespaceLabelName: eslabel.ClusterNamespaceLabelName, - Predicates: predicates.WithPredicates(predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)), + Predicates: predicates.WithPredicates(predicates.ManagedNamespacePredicate), ElasticsearchUserCreation: &association.ElasticsearchUserCreation{ ElasticsearchRef: func(c k8s.Client, association commonv1.Association) (bool, commonv1.ObjectSelector, error) { diff --git a/pkg/controller/autoscaling/elasticsearch.go b/pkg/controller/autoscaling/elasticsearch.go index 288f1a7a67e..fa9000981fd 100644 --- a/pkg/controller/autoscaling/elasticsearch.go +++ b/pkg/controller/autoscaling/elasticsearch.go @@ -29,5 +29,5 @@ func Add(mgr manager.Manager, p operator.Parameters) error { return err } // Watch for changes on Elasticsearch clusters. - return c.Watch(&source.Kind{Type: &esv1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, predicates.ManagedNamespacesPredicate(p.ManagedNamespaces)) + return c.Watch(&source.Kind{Type: &esv1.Elasticsearch{}}, &handler.EnqueueRequestForObject{}, predicates.ManagedNamespacePredicate) } diff --git a/pkg/controller/beat/controller.go b/pkg/controller/beat/controller.go index 57abd7ec2fa..3d05814efa6 100644 --- a/pkg/controller/beat/controller.go +++ b/pkg/controller/beat/controller.go @@ -56,7 +56,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, r, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, r, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler. diff --git a/pkg/controller/common/predicates/predicate_test.go b/pkg/controller/common/predicates/predicate_test.go index b2c5f9ad779..9edeeb3c2bf 100644 --- a/pkg/controller/common/predicates/predicate_test.go +++ b/pkg/controller/common/predicates/predicate_test.go @@ -57,7 +57,7 @@ func TestManagedNamespacesPredicate(t *testing.T) { require.NoError(t, err) bldr := builder.ControllerManagedBy(mgr). - For(&appsv1.Deployment{}, builder.WithPredicates(predicates.ManagedNamespacesPredicate([]string{managedNamespace}))) + For(&appsv1.Deployment{}, builder.WithPredicates(predicates.NewManagedNamespacesPredicate([]string{managedNamespace}))) require.NoError(t, bldr.Complete(reconciler)) ctx, cancel := context.WithCancel(context.Background()) diff --git a/pkg/controller/common/predicates/predicates.go b/pkg/controller/common/predicates/predicates.go index 2fb7b669536..12c9560123a 100644 --- a/pkg/controller/common/predicates/predicates.go +++ b/pkg/controller/common/predicates/predicates.go @@ -5,48 +5,44 @@ package predicates import ( + "k8s.io/utils/strings/slices" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" ) -func namespaceInSlice(namespace string, namespaces []string) bool { - // If the operator is managing all namespaces, - // never ignore any namespace. - if len(namespaces) == 0 { - return true - } - for _, ns := range namespaces { - if namespace == ns { - return true - } - } - return false -} - -// WithPredicates is a helper function to convert one or more predicates -// into a slice of predicates. -func WithPredicates(predicates ...predicate.Predicate) []predicate.Predicate { - return predicates -} +// ManagedNamespacePredicate is a predicate that will ignore events that exist +// outside of the namespaces that the operator manages. +var ManagedNamespacePredicate predicate.Predicate -// ManagedNamespacesPredicate will return a predicate that will ignore events +// NewManagedNamespacesPredicate will return a predicate that will ignore events // that exist outside of the given managed namespaces, -func ManagedNamespacesPredicate(managedNamespaces []string) predicate.Predicate { +func NewManagedNamespacesPredicate(managedNamespaces []string) predicate.Predicate { return predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { // Ignore resources that do not exist within the managed namespaces - return namespaceInSlice(e.Object.GetNamespace(), managedNamespaces) + return IsNamespaceManaged(e.Object.GetNamespace(), managedNamespaces) }, UpdateFunc: func(e event.UpdateEvent) bool { // Ignore resources that do not exist within the managed namespaces - return namespaceInSlice(e.ObjectNew.GetNamespace(), managedNamespaces) + return IsNamespaceManaged(e.ObjectNew.GetNamespace(), managedNamespaces) }, DeleteFunc: func(e event.DeleteEvent) bool { // Ignore resources that do not exist within the managed namespaces - return namespaceInSlice(e.Object.GetNamespace(), managedNamespaces) + return IsNamespaceManaged(e.Object.GetNamespace(), managedNamespaces) }, GenericFunc: func(e event.GenericEvent) bool { return namespaceInSlice(e.Object.GetNamespace(), managedNamespaces) }, } } + +// IsNamespaceManaged returns true if the namespace is managed by the operator. +func IsNamespaceManaged(namespace string, managedNamespaces []string) bool { + return len(managedNamespaces) == 0 || slices.Contains(managedNamespaces, namespace) +} + +// WithPredicates is a helper function to convert one or more predicates +// into a slice of predicates. +func WithPredicates(predicates ...predicate.Predicate) []predicate.Predicate { + return predicates +} diff --git a/pkg/controller/elasticsearch/elasticsearch_controller.go b/pkg/controller/elasticsearch/elasticsearch_controller.go index 20c68eb3adf..f193f1ba298 100644 --- a/pkg/controller/elasticsearch/elasticsearch_controller.go +++ b/pkg/controller/elasticsearch/elasticsearch_controller.go @@ -62,7 +62,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, reconciler, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, reconciler, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/enterprisesearch/enterprisesearch_controller.go b/pkg/controller/enterprisesearch/enterprisesearch_controller.go index 01d5a3ed1d8..d11f8f0fde1 100644 --- a/pkg/controller/enterprisesearch/enterprisesearch_controller.go +++ b/pkg/controller/enterprisesearch/enterprisesearch_controller.go @@ -57,7 +57,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, reconciler, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, reconciler, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/kibana/controller.go b/pkg/controller/kibana/controller.go index 80777bc1e9f..19ff99c936f 100644 --- a/pkg/controller/kibana/controller.go +++ b/pkg/controller/kibana/controller.go @@ -53,7 +53,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, reconciler, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, reconciler, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/license/license_controller.go b/pkg/controller/license/license_controller.go index 4e4dfc0fff3..d5f75ddf848 100644 --- a/pkg/controller/license/license_controller.go +++ b/pkg/controller/license/license_controller.go @@ -67,7 +67,7 @@ func Add(mgr manager.Manager, p operator.Parameters) error { if err != nil { return err } - return addWatches(c, r.Client, predicates.ManagedNamespacesPredicate(p.ManagedNamespaces)) + return addWatches(c, r.Client, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/license/license_controller_integration_test.go b/pkg/controller/license/license_controller_integration_test.go index c2062aaa017..8a101b3c59d 100644 --- a/pkg/controller/license/license_controller_integration_test.go +++ b/pkg/controller/license/license_controller_integration_test.go @@ -49,7 +49,7 @@ func TestReconcile(t *testing.T) { if err != nil { return err } - return addWatches(c, r.Client, p) + return addWatches(c, r.Client) }, operator.Parameters{}) defer stop() diff --git a/pkg/controller/maps/controller.go b/pkg/controller/maps/controller.go index bed5e209ae0..498b9302525 100644 --- a/pkg/controller/maps/controller.go +++ b/pkg/controller/maps/controller.go @@ -59,7 +59,7 @@ func Add(mgr manager.Manager, params operator.Parameters) error { if err != nil { return err } - return addWatches(c, reconciler, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return addWatches(c, reconciler, predicates.ManagedNamespacePredicate) } // newReconciler returns a new reconcile.Reconciler diff --git a/pkg/controller/remoteca/controller.go b/pkg/controller/remoteca/controller.go index 79da534d39f..67dd6270905 100644 --- a/pkg/controller/remoteca/controller.go +++ b/pkg/controller/remoteca/controller.go @@ -50,7 +50,7 @@ func Add(mgr manager.Manager, accessReviewer rbac.AccessReviewer, params operato if err != nil { return err } - return AddWatches(c, r, predicates.ManagedNamespacesPredicate(params.ManagedNamespaces)) + return AddWatches(c, r, predicates.ManagedNamespacePredicate) } // NewReconciler returns a new reconcile.Reconciler