From e8c158df7a3f5d484dfb03e5b07b5ff69cbaa027 Mon Sep 17 00:00:00 2001 From: May Zhang Date: Fri, 20 Oct 2023 15:10:34 -0700 Subject: [PATCH 1/2] if applicationNamespaces is not provided as input parameter, then use namespaced appClient Signed-off-by: May Zhang --- notification_controller/controller/controller.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/notification_controller/controller/controller.go b/notification_controller/controller/controller.go index 1ad2ab361ab93..c828836c3cb24 100644 --- a/notification_controller/controller/controller.go +++ b/notification_controller/controller/controller.go @@ -61,7 +61,13 @@ func NewController( secretName string, configMapName string, ) *notificationController { - appClient := client.Resource(applications) + var appClient dynamic.ResourceInterface + namespaceableAppClient := client.Resource(applications) + appClient = namespaceableAppClient + if len(applicationNamespaces) == 0 { + appClient = namespaceableAppClient.Namespace(namespace) + } + appClient = client.Resource(applications) appInformer := newInformer(appClient, namespace, applicationNamespaces, appLabelSelector) appProjInformer := newInformer(newAppProjClient(client, namespace), namespace, []string{namespace}, "") secretInformer := k8s.NewSecretInformer(k8sClient, namespace, secretName) @@ -74,7 +80,7 @@ func NewController( appInformer: appInformer, appProjInformer: appProjInformer, apiFactory: apiFactory} - res.ctrl = controller.NewController(appClient, appInformer, apiFactory, + res.ctrl = controller.NewController(namespaceableAppClient, appInformer, apiFactory, controller.WithSkipProcessing(func(obj v1.Object) (bool, string) { app, ok := (obj).(*unstructured.Unstructured) if !ok { From a0f7f3552f4136c32ed66b9bbd5cb597c8e4bbad Mon Sep 17 00:00:00 2001 From: May Zhang Date: Mon, 23 Oct 2023 13:20:05 -0700 Subject: [PATCH 2/2] fix go lint error Signed-off-by: May Zhang --- notification_controller/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification_controller/controller/controller.go b/notification_controller/controller/controller.go index c828836c3cb24..a08c0cc1f9714 100644 --- a/notification_controller/controller/controller.go +++ b/notification_controller/controller/controller.go @@ -67,7 +67,7 @@ func NewController( if len(applicationNamespaces) == 0 { appClient = namespaceableAppClient.Namespace(namespace) } - appClient = client.Resource(applications) + appInformer := newInformer(appClient, namespace, applicationNamespaces, appLabelSelector) appProjInformer := newInformer(newAppProjClient(client, namespace), namespace, []string{namespace}, "") secretInformer := k8s.NewSecretInformer(k8sClient, namespace, secretName)