@@ -75,7 +75,7 @@ func (r *ConsumerReconciler) listConsumersForGateway(ctx context.Context, obj cl
7575 r .Log .Error (err , "failed to list consumers" )
7676 return nil
7777 }
78- var requests []reconcile.Request
78+ requests := make ( []reconcile.Request , 0 , len ( consumerList . Items ))
7979 for _ , consumer := range consumerList .Items {
8080 requests = append (requests , reconcile.Request {
8181 NamespacedName : client.ObjectKey {
@@ -100,12 +100,10 @@ func (r *ConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
100100 }
101101
102102 if err := r .Provider .Delete (ctx , consumer ); err != nil {
103- r .Log .Error (err , "failed to delete consumer" , "consumer" , consumer )
104103 return ctrl.Result {}, err
105104 }
106105 return ctrl.Result {}, nil
107106 }
108- r .Log .Error (err , "failed to get consumer" , "consumer" , consumer )
109107 return ctrl.Result {}, err
110108 }
111109
@@ -123,23 +121,20 @@ func (r *ConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
123121 }
124122
125123 if err := r .updateStatus (ctx , consumer , statusErr ); err != nil {
126- r .Log .Error (err , "failed to update consumer status" , "consumer" , consumer )
127124 return ctrl.Result {}, err
128125 }
129126
130127 return ctrl.Result {}, nil
131128}
132129
133130func (r * ConsumerReconciler ) processSepc (ctx context.Context , tctx * provider.TranslateContext , consumer * v1alpha1.Consumer ) error {
134- r .Log .Info ("Processing consumer" , "name" , consumer .Name , "namespace" , consumer .Namespace )
135-
136131 for _ , credential := range consumer .Spec .Credentials {
137132 if credential .SecretRef == nil {
138133 continue
139134 }
140135 ns := consumer .GetNamespace ()
141136 if credential .SecretRef .Namespace != nil {
142- ns = string ( * credential .SecretRef .Namespace )
137+ ns = * credential .SecretRef .Namespace
143138 }
144139 secret := corev1.Secret {}
145140 if err := r .Get (ctx , client.ObjectKey {
@@ -194,7 +189,7 @@ func (r *ConsumerReconciler) checkGatewayRef(object client.Object) bool {
194189 }
195190 ns := consumer .GetNamespace ()
196191 if consumer .Spec .GatewayRef .Namespace != nil {
197- ns = string ( * consumer .Spec .GatewayRef .Namespace )
192+ ns = * consumer .Spec .GatewayRef .Namespace
198193 }
199194 gateway := & gatewayv1.Gateway {}
200195 if err := r .Get (context .TODO (), client.ObjectKey {
@@ -204,5 +199,10 @@ func (r *ConsumerReconciler) checkGatewayRef(object client.Object) bool {
204199 r .Log .Error (err , "failed to get gateway" , "gateway" , consumer .Spec .GatewayRef .Name )
205200 return false
206201 }
207- return true
202+ gatewayClass := & gatewayv1.GatewayClass {}
203+ if err := r .Client .Get (context .Background (), client.ObjectKey {Name : string (gateway .Spec .GatewayClassName )}, gatewayClass ); err != nil {
204+ r .Log .Error (err , "failed to get gateway class" , "gateway" , gateway .GetName (), "gatewayclass" , gateway .Spec .GatewayClassName )
205+ return false
206+ }
207+ return matchesController (string (gatewayClass .Spec .ControllerName ))
208208}
0 commit comments