From 33e66d85028821cdd8c17caac8449f853e5df762 Mon Sep 17 00:00:00 2001 From: anirudhAgniRedhat Date: Wed, 7 Aug 2024 10:56:52 +0530 Subject: [PATCH] Added watch for subscription and SMCP --- .../controller/gatewayclass/controller.go | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/operator/controller/gatewayclass/controller.go b/pkg/operator/controller/gatewayclass/controller.go index 800214ac53..ac31006f2f 100644 --- a/pkg/operator/controller/gatewayclass/controller.go +++ b/pkg/operator/controller/gatewayclass/controller.go @@ -5,6 +5,9 @@ import ( logf "github.com/openshift/cluster-ingress-operator/pkg/log" + maistrav2 "github.com/maistra/istio-operator/pkg/apis/maistra/v2" + operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" + "k8s.io/client-go/tools/record" gatewayapiv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" @@ -14,6 +17,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/predicate" @@ -61,6 +65,24 @@ func NewUnmanaged(mgr manager.Manager, config Config) (controller.Controller, er if err := c.Watch(source.Kind(operatorCache, &gatewayapiv1beta1.GatewayClass{}), &handler.EnqueueRequestForObject{}, isOurGatewayClass, predicate.Not(isIstioGatewayClass)); err != nil { return nil, err } + if err := c.Watch(source.Kind(operatorCache, &maistrav2.ServiceMeshControlPlane{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ + CreateFunc: func(e event.CreateEvent) bool { return false }, + DeleteFunc: func(e event.DeleteEvent) bool { return true }, + UpdateFunc: func(e event.UpdateEvent) bool { return false }, + GenericFunc: func(e event.GenericEvent) bool { return false }, + }); err != nil { + return nil, err + } + + if err := c.Watch(source.Kind(operatorCache, &operatorsv1alpha1.Subscription{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ + CreateFunc: func(e event.CreateEvent) bool { return false }, + DeleteFunc: func(e event.DeleteEvent) bool { return true }, + UpdateFunc: func(e event.UpdateEvent) bool { return false }, + GenericFunc: func(e event.GenericEvent) bool { return false }, + }); err != nil { + return nil, err + } + return c, nil }