From 41c7e73cfc19a73a4d5147dee0e943a67fae5750 Mon Sep 17 00:00:00 2001 From: anirudhAgniRedhat Date: Fri, 9 Aug 2024 16:57:04 +0530 Subject: [PATCH] Added watch for SMCP --- .../controller/gatewayclass/controller.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/operator/controller/gatewayclass/controller.go b/pkg/operator/controller/gatewayclass/controller.go index 1fbe3b01c5..f0cd8ef081 100644 --- a/pkg/operator/controller/gatewayclass/controller.go +++ b/pkg/operator/controller/gatewayclass/controller.go @@ -2,6 +2,7 @@ package gatewayclass import ( "context" + maistrav2 "github.com/maistra/istio-operator/pkg/apis/maistra/v2" logf "github.com/openshift/cluster-ingress-operator/pkg/log" operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" "k8s.io/client-go/tools/record" @@ -68,12 +69,17 @@ func NewUnmanaged(mgr manager.Manager, config Config) (controller.Controller, er // }} //} - //isOurSMCP := predicate.NewPredicateFuncs(func(o client.Object) bool { - // return o.GetName() == OpenShiftDefaultGatewayClassName - //}) - //if err := c.Watch(source.Kind(operatorCache, &maistrav2.ServiceMeshControlPlane{}), &handler.EnqueueRequestForObject{}, isOurSMCP); err != nil { - // return nil, err - //} + isOurSMCP := predicate.NewPredicateFuncs(func(o client.Object) bool { + return o.GetName() == OpenShiftDefaultGatewayClassName + }) + if err = c.Watch(source.Kind[client.Object](operatorCache, &maistrav2.ServiceMeshControlPlane{}, &handler.EnqueueRequestForObject{}, isOurSMCP, 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 + } //toServiceMeshSubscription := func(ctx context.Context, _ client.Object) []reconcile.Request { // return []reconcile.Request{{