@@ -11,16 +11,17 @@ import (
1111
1212 configv1 "github.com/openshift/api/config/v1"
1313
14+ apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1415 "k8s.io/apimachinery/pkg/types"
1516
1617 "sigs.k8s.io/controller-runtime/pkg/client"
1718 "sigs.k8s.io/controller-runtime/pkg/controller"
18- "sigs.k8s.io/controller-runtime/pkg/event"
1919 "sigs.k8s.io/controller-runtime/pkg/handler"
2020 "sigs.k8s.io/controller-runtime/pkg/manager"
2121 "sigs.k8s.io/controller-runtime/pkg/predicate"
2222 "sigs.k8s.io/controller-runtime/pkg/reconcile"
2323 "sigs.k8s.io/controller-runtime/pkg/source"
24+ gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
2425)
2526
2627const (
@@ -60,15 +61,12 @@ func New(mgr manager.Manager, config Config) (controller.Controller, error) {
6061 }
6162
6263 // watch for CRDs
63- for i := range managedCRDs {
64- if err = c .Watch (source .Kind [client.Object ](operatorCache , managedCRDs [i ], handler .EnqueueRequestsFromMapFunc (toFeatureGate ), predicate.Funcs {
65- CreateFunc : func (e event.CreateEvent ) bool { return false },
66- DeleteFunc : func (e event.DeleteEvent ) bool { return true },
67- UpdateFunc : func (e event.UpdateEvent ) bool { return false },
68- GenericFunc : func (e event.GenericEvent ) bool { return false },
69- })); err != nil {
70- return nil , err
71- }
64+ crdPredicate := predicate .NewPredicateFuncs (func (o client.Object ) bool {
65+ return o .(* apiextensionsv1.CustomResourceDefinition ).Spec .Group == gatewayapiv1 .GroupName
66+ })
67+
68+ if err := c .Watch (source .Kind [client.Object ](operatorCache , & apiextensionsv1.CustomResourceDefinition {}, handler .EnqueueRequestsFromMapFunc (toFeatureGate ), crdPredicate )); err != nil {
69+ return nil , err
7270 }
7371 return c , nil
7472}
0 commit comments