From 6e182e7833ef95ad6fa5a68489139d528dcff7a7 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Tue, 1 Oct 2024 14:12:06 +0200 Subject: [PATCH] consoleplugin watcher with predicate on label Signed-off-by: Eguzki Astiz Lezaun --- controllers/state_of_the_world.go | 5 ++++- pkg/openshift/consoleplugin/common.go | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/controllers/state_of_the_world.go b/controllers/state_of_the_world.go index cd08a4690..a34d61675 100644 --- a/controllers/state_of_the_world.go +++ b/controllers/state_of_the_world.go @@ -32,6 +32,7 @@ import ( kuadrantgatewayapi "github.com/kuadrant/kuadrant-operator/pkg/library/gatewayapi" "github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant" "github.com/kuadrant/kuadrant-operator/pkg/openshift" + "github.com/kuadrant/kuadrant-operator/pkg/openshift/consoleplugin" ) var ( @@ -137,7 +138,9 @@ func NewPolicyMachineryController(manager ctrlruntime.Manager, client *dynamic.D logger.Info("console plugin is not installed, skipping related watches and reconcilers", "err", err) } else { controllerOpts = append(controllerOpts, - controller.WithRunnable("consoleplugin watcher", controller.Watch(&consolev1.ConsolePlugin{}, openshift.ConsolePluginsResource, metav1.NamespaceAll)), + controller.WithRunnable("consoleplugin watcher", controller.Watch( + &consolev1.ConsolePlugin{}, openshift.ConsolePluginsResource, metav1.NamespaceAll, + controller.FilterResourcesByLabel[*consolev1.ConsolePlugin](fmt.Sprintf("%s=%s", consoleplugin.AppLabelKey, consoleplugin.AppLabelValue)))), controller.WithObjectKinds(openshift.ConsolePluginGVK.GroupKind()), // TODO: add object links ) diff --git a/pkg/openshift/consoleplugin/common.go b/pkg/openshift/consoleplugin/common.go index cca19e2fd..c5e1b202d 100644 --- a/pkg/openshift/consoleplugin/common.go +++ b/pkg/openshift/consoleplugin/common.go @@ -5,9 +5,14 @@ const ( KuadrantPluginComponent = "kuadrant-plugin" ) +var ( + AppLabelKey = "app" + AppLabelValue = KuadrantConsoleName +) + func CommonLabels() map[string]string { return map[string]string{ - "app": KuadrantConsoleName, + AppLabelKey: AppLabelValue, "app.kubernetes.io/component": KuadrantPluginComponent, "app.kubernetes.io/managed-by": "kuadrant-operator", "app.kubernetes.io/instance": KuadrantConsoleName,