From 24c6bbf98ac884202c15e984b09aa5b5a78f7acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20Burzy=C5=84ski?= Date: Mon, 17 Jun 2024 15:38:16 +0200 Subject: [PATCH] chore: enable nakedret linter --- .golangci.yaml | 1 + controller/controlplane/controller_watch.go | 4 ++-- controller/gateway/controller_watch.go | 12 ++++++------ controller/pkg/secrets/cert.go | 5 ++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 372ad596b..9d3f384dc 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -32,6 +32,7 @@ linters: - unparam - unused - wastedassign + - nakedret linters-settings: gci: sections: diff --git a/controller/controlplane/controller_watch.go b/controller/controlplane/controller_watch.go index 026480ac5..91ddfa88b 100644 --- a/controller/controlplane/controller_watch.go +++ b/controller/controlplane/controller_watch.go @@ -203,7 +203,7 @@ func (r *Reconciler) getControlPlanesFromDataPlane(ctx context.Context, obj clie "failed to map ControlPlane on DataPlane", "expected", "DataPlane", "found", reflect.TypeOf(obj), ) - return + return nil } controlPlaneList := &operatorv1beta1.ControlPlaneList{} @@ -213,7 +213,7 @@ func (r *Reconciler) getControlPlanesFromDataPlane(ctx context.Context, obj clie index.DataPlaneNameIndex: dataplane.Name, }); err != nil { log.FromContext(ctx).Error(err, "failed to map ControlPlane on DataPlane") - return + return nil } recs = make([]reconcile.Request, 0, len(controlPlaneList.Items)) diff --git a/controller/gateway/controller_watch.go b/controller/gateway/controller_watch.go index d123c2d73..b149cb48e 100644 --- a/controller/gateway/controller_watch.go +++ b/controller/gateway/controller_watch.go @@ -128,7 +128,7 @@ func (r *Reconciler) listGatewaysForGatewayClass(ctx context.Context, obj client return } -func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj client.Object) (recs []reconcile.Request) { +func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj client.Object) []reconcile.Request { logger := log.FromContext(ctx) gatewayConfig, ok := obj.(*operatorv1beta1.GatewayConfiguration) @@ -138,7 +138,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien "failed to run map funcs", "expected", "GatewayConfiguration", "found", reflect.TypeOf(obj), ) - return + return nil } gatewayClassList := new(gatewayv1.GatewayClassList) @@ -148,7 +148,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien "failed to run map funcs", "error", err.Error(), ) - return + return nil } matchingGatewayClasses := make(map[string]struct{}) @@ -168,9 +168,10 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien "failed to run map funcs", "error", err.Error(), ) - return + return nil } + var recs []reconcile.Request for _, gateway := range gatewayList.Items { if _, ok := matchingGatewayClasses[string(gateway.Spec.GatewayClassName)]; ok { recs = append(recs, reconcile.Request{ @@ -181,8 +182,7 @@ func (r *Reconciler) listGatewaysForGatewayConfig(ctx context.Context, obj clien }) } } - - return + return recs } // listReferenceGrantsForGateway is a watch predicate which finds all Gateways mentioned in a From clause for a diff --git a/controller/pkg/secrets/cert.go b/controller/pkg/secrets/cert.go index 32db56899..3fa7870b2 100644 --- a/controller/pkg/secrets/cert.go +++ b/controller/pkg/secrets/cert.go @@ -434,8 +434,7 @@ func ensureContainerImageUpdated(container *corev1.Container, imageVersionStr st imageParts := strings.Split(container.Image, ":") if len(imageParts) > 3 { - err = fmt.Errorf("invalid container image found: %s", container.Image) - return + return false, fmt.Errorf("invalid container image found: %s", container.Image) } // This is a special case for registries that specify a non default port, @@ -462,5 +461,5 @@ func ensureContainerImageUpdated(container *corev1.Container, imageVersionStr st updated = true } - return + return updated, nil }