From 5510a07d7aa7b2209121ea33595a1b7c189c2bb6 Mon Sep 17 00:00:00 2001 From: Jan Knipper Date: Tue, 17 Dec 2024 13:53:15 +0100 Subject: [PATCH] Update linter, fix loop references --- .github/workflows/tests.yaml | 2 +- .golangci.yaml | 2 +- Dockerfile.kubernikus | 2 +- Dockerfile.kubernikus-binaries | 2 +- pkg/controller/flight/factory.go | 1 - test/e2e/network_test.go | 15 --------------- 6 files changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0dc7d1d179..cf7ec1f596 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -23,7 +23,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.59.1 + version: v1.62.2 - name: Tests run: /bin/bash -c make gotest - name: Build e2e diff --git a/.golangci.yaml b/.golangci.yaml index 582ca67163..7722d91ec2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -2,7 +2,7 @@ run: timeout: 5m linters: enable: - - exportloopref + - copyloopvar - gci - gofmt disable: diff --git a/Dockerfile.kubernikus b/Dockerfile.kubernikus index 32f141d9a6..3070c2471e 100644 --- a/Dockerfile.kubernikus +++ b/Dockerfile.kubernikus @@ -2,7 +2,7 @@ ARG DOCS_IMAGE=keppel.eu-de-1.cloud.sap/ccloud/kubernikus-docs-builder:latest FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/golang:1.23-alpine3.21 as builder WORKDIR /app RUN apk add --no-cache make bash git curl gcc musl-dev -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2 COPY . . ENV GOARCH=amd64 ARG VERSION diff --git a/Dockerfile.kubernikus-binaries b/Dockerfile.kubernikus-binaries index ad2abb2139..958323d8ac 100644 --- a/Dockerfile.kubernikus-binaries +++ b/Dockerfile.kubernikus-binaries @@ -1,7 +1,7 @@ FROM keppel.eu-de-1.cloud.sap/ccloud-dockerhub-mirror/library/golang:1.23-alpine3.21 as builder RUN apk add --no-cache make git curl bash gcc musl-dev WORKDIR /app -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2 COPY . . ENV GOARCH=amd64 ARG VERSION diff --git a/pkg/controller/flight/factory.go b/pkg/controller/flight/factory.go index 4b327cd88f..17c015b76a 100644 --- a/pkg/controller/flight/factory.go +++ b/pkg/controller/flight/factory.go @@ -68,7 +68,6 @@ func (d *flightReconcilerFactory) getInstances(kluster *v1.Kluster, client opens return nil, err } else { for _, n := range poolNodes { - n := n // copy to avoid referencing the loop variable instances = append(instances, &instance{Node: n, pool: pool.Name}) } } diff --git a/test/e2e/network_test.go b/test/e2e/network_test.go index 38506694d1..82fddeea4c 100644 --- a/test/e2e/network_test.go +++ b/test/e2e/network_test.go @@ -88,8 +88,6 @@ func (n *NetworkTests) DeleteNamespace(t *testing.T) { func (n *NetworkTests) CreatePods(t *testing.T) { for _, node := range n.Nodes.Items { - node := node - t.Run(fmt.Sprintf("CreatePodForNode-%v", node.Name), func(t *testing.T) { _, err := n.Kubernetes.ClientSet.CoreV1().Pods(n.Namespace).Create(context.Background(), &v1.Pod{ ObjectMeta: meta_v1.ObjectMeta{ @@ -139,8 +137,6 @@ func (n *NetworkTests) WaitForKubeDNSRunning(t *testing.T) { func (n *NetworkTests) CreateServices(t *testing.T) { for _, node := range n.Nodes.Items { - node := node - t.Run(fmt.Sprintf("CreateServiceForNode-%v", node.Name), func(t *testing.T) { service := &v1.Service{ ObjectMeta: meta_v1.ObjectMeta{ @@ -188,11 +184,7 @@ func (n *NetworkTests) TestPods(t *testing.T) { assert.Equal(t, len(n.Nodes.Items), len(pods.Items), "There should one pod for each node") for _, target := range pods.Items { - target := target - for _, source := range pods.Items { - source := source - t.Run(fmt.Sprintf("%v->%v", source.Status.PodIP, target.Status.PodIP), func(t *testing.T) { var stdout string cmd := strings.Split(fmt.Sprintf("curl -f --max-time 5 http://%v:%v", target.Status.PodIP, ServeHostnamePort), " ") @@ -224,11 +216,7 @@ func (n *NetworkTests) TestServices(t *testing.T) { assert.Equal(t, len(n.Nodes.Items), len(pods.Items), "There should one pod for each node") for _, target := range services.Items { - target := target - for _, source := range pods.Items { - source := source - t.Run(fmt.Sprintf("%v->%v", source.Status.PodIP, target.Spec.ClusterIP), func(t *testing.T) { var stdout string cmd := strings.Split(fmt.Sprintf("curl -f --max-time 5 http://%v:%v", target.Spec.ClusterIP, ServeHostnamePort), " ") @@ -261,12 +249,9 @@ func (n *NetworkTests) TestServicesWithDNS(t *testing.T) { assert.Equal(t, len(n.Nodes.Items), len(pods.Items), "There should one pod for each node") for _, target := range services.Items { - target := target service := fmt.Sprintf("%s.%s.svc", target.GetName(), target.GetNamespace()) for _, source := range pods.Items { - source := source - t.Run(fmt.Sprintf("%v->%v", source.Status.PodIP, service), func(t *testing.T) { var stdout string cmd := []string{"dig", service}