Skip to content

Commit

Permalink
Update linter, fix loop references (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
jknipper authored Dec 17, 2024
1 parent 72d1e63 commit 2a74e3a
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ run:
timeout: 5m
linters:
enable:
- exportloopref
- copyloopvar
- gci
- gofmt
disable:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.kubernikus
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.kubernikus-binaries
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/flight/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
}
Expand Down
15 changes: 0 additions & 15 deletions test/e2e/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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), " ")
Expand Down Expand Up @@ -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), " ")
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 2a74e3a

Please sign in to comment.