From a3f70ca44d740357edc76861141fbcf0ca73d20e Mon Sep 17 00:00:00 2001 From: Travis Raines <571832+rainest@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:06:39 -0700 Subject: [PATCH] chore(controllers) fix linter errors --- .../generators/controllers/networking/main.go | 7 ++- .../configuration/zz_generated_controllers.go | 43 ++++++++----------- internal/controllers/knative/knative.go | 7 ++- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go index 86770a63c91..ba6f20ec4e7 100644 --- a/hack/generators/controllers/networking/main.go +++ b/hack/generators/controllers/networking/main.go @@ -490,8 +490,8 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) listClassless(obj client.Object) return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -579,9 +579,8 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } {{- end}} diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go index 7bb41b73098..f3cdca3d8c5 100644 --- a/internal/controllers/configuration/zz_generated_controllers.go +++ b/internal/controllers/configuration/zz_generated_controllers.go @@ -325,8 +325,8 @@ func (r *NetV1IngressReconciler) listClassless(obj client.Object) []reconcile.Re return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -409,9 +409,8 @@ func (r *NetV1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -550,8 +549,8 @@ func (r *NetV1Beta1IngressReconciler) listClassless(obj client.Object) []reconci return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -634,9 +633,8 @@ func (r *NetV1Beta1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Re if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -705,8 +703,8 @@ func (r *ExtV1Beta1IngressReconciler) listClassless(obj client.Object) []reconci return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -789,9 +787,8 @@ func (r *ExtV1Beta1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Re if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -986,8 +983,8 @@ func (r *KongV1KongClusterPluginReconciler) listClassless(obj client.Object) []r return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -1103,8 +1100,8 @@ func (r *KongV1KongConsumerReconciler) listClassless(obj client.Object) []reconc return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -1236,8 +1233,8 @@ func (r *KongV1Beta1TCPIngressReconciler) listClassless(obj client.Object) []rec return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -1320,9 +1317,8 @@ func (r *KongV1Beta1TCPIngressReconciler) Reconcile(ctx context.Context, req ctr if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -1391,8 +1387,8 @@ func (r *KongV1Beta1UDPIngressReconciler) listClassless(obj client.Object) []rec return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -1475,9 +1471,8 @@ func (r *KongV1Beta1UDPIngressReconciler) Reconcile(ctx context.Context, req ctr if len(obj.Status.LoadBalancer.Ingress) != len(addrs) || !reflect.DeepEqual(obj.Status.LoadBalancer.Ingress, addrs) { obj.Status.LoadBalancer.Ingress = addrs return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil diff --git a/internal/controllers/knative/knative.go b/internal/controllers/knative/knative.go index bf247b90123..b1208ed1f83 100644 --- a/internal/controllers/knative/knative.go +++ b/internal/controllers/knative/knative.go @@ -92,8 +92,8 @@ func (r *Knativev1alpha1IngressReconciler) listClassless(obj client.Object) []re return nil } var recs []reconcile.Request - for _, resource := range resourceList.Items { - if ctrlutils.IsIngressClassEmpty(&resource) { + for i, resource := range resourceList.Items { + if ctrlutils.IsIngressClassEmpty(&resourceList.Items[i]) { recs = append(recs, reconcile.Request{ NamespacedName: types.NamespacedName{ Namespace: resource.Namespace, @@ -188,9 +188,8 @@ func (r *Knativev1alpha1IngressReconciler) Reconcile(ctx context.Context, req ct ingressCondSet.Manage(&obj.Status).MarkTrue(knativev1alpha1.IngressConditionNetworkConfigured) obj.Status.ObservedGeneration = obj.Generation return ctrl.Result{}, r.Status().Update(ctx, obj) - } else { - log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } + log.V(util.DebugLevel).Info("status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil