Skip to content

Commit 5e9eeb1

Browse files
authored
Use go 1.24 and golangci-lint v2 (#1719)
1 parent 685174b commit 5e9eeb1

File tree

818 files changed

+57734
-19577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

818 files changed

+57734
-19577
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ jobs:
88
build-lint-test:
99
name: Build, lint, test
1010
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
go: ['1.23']
1411
steps:
1512
- name: install make
1613
run: sudo apt-get install make
1714
- name: set up go 1.x
1815
uses: actions/setup-go@v3
1916
with:
20-
go-version: ${{ matrix.go }}
17+
go-version: '1.24'
2118
- name: checkout
2219
uses: actions/checkout@v3
2320
- name: check format
@@ -27,7 +24,6 @@ jobs:
2724
- name: check clean vendors
2825
run: go mod vendor
2926
- name: Report coverage
30-
if: ${{ matrix.go == '1.23' }}
3127
uses: codecov/codecov-action@v4
3228
with:
3329
files: ./cover.out

.github/workflows/push_image.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ jobs:
1515
push-image:
1616
name: push image
1717
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
go: ['1.23']
2118
steps:
2219
- name: install make
2320
run: sudo apt-get install make
2421
- name: set up go 1.x
2522
uses: actions/setup-go@v3
2623
with:
27-
go-version: ${{ matrix.go }}
24+
go-version: '1.24'
2825
- name: checkout
2926
uses: actions/checkout@v3
3027
- name: docker login to quay.io
@@ -59,16 +56,13 @@ jobs:
5956
codecov:
6057
name: Codecov upload
6158
runs-on: ubuntu-latest
62-
strategy:
63-
matrix:
64-
go: ['1.23']
6559
steps:
6660
- name: install make
6761
run: sudo apt-get install make
6862
- name: set up go 1.x
6963
uses: actions/setup-go@v3
7064
with:
71-
go-version: ${{ matrix.go }}
65+
go-version: '1.24'
7266
- name: checkout
7367
uses: actions/checkout@v3
7468
- name: Test

.github/workflows/push_image_pr.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@ jobs:
1515
if: ${{ github.event.label.name == 'ok-to-test' }}
1616
name: push PR image
1717
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
go: ['1.23']
2118
steps:
2219
- name: install make
2320
run: sudo apt-get install make
2421
- name: set up go 1.x
2522
uses: actions/setup-go@v3
2623
with:
27-
go-version: ${{ matrix.go }}
24+
go-version: '1.24'
2825
- name: checkout
2926
uses: actions/checkout@v3
3027
with:

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
push-image:
1515
name: push image
1616
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
go: ['1.23']
2017
steps:
2118
- name: checkout
2219
uses: actions/checkout@v3
@@ -42,7 +39,7 @@ jobs:
4239
- name: set up go 1.x
4340
uses: actions/setup-go@v3
4441
with:
45-
go-version: ${{ matrix.go }}
42+
go-version: '1.24'
4643
- name: build operator
4744
run: |
4845
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.tag }} CLEAN_BUILD=1 make image-build

.golangci.yml

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,56 @@
1+
version: "2"
2+
run:
3+
go: "1.23"
14
linters:
25
enable:
3-
- errcheck
4-
- errorlint
6+
- copyloopvar
57
- cyclop
8+
- errcheck
69
- errname
10+
- errorlint
711
- exhaustive
8-
- copyloopvar
912
- gocritic
10-
- gofmt
11-
- gosimple
1213
- govet
1314
- ineffassign
1415
- revive
1516
- staticcheck
16-
- stylecheck
17-
- typecheck
1817
- unused
19-
run:
20-
go: "1.23"
21-
linters-settings:
22-
gocritic:
23-
enabled-checks:
24-
- hugeParam
25-
- rangeExprCopy
26-
- rangeValCopy
27-
- indexAlloc
28-
settings:
29-
ifElseChain:
30-
minThreshold: 3
31-
cyclop:
32-
max-complexity: 20
18+
settings:
19+
cyclop:
20+
max-complexity: 20
21+
gocritic:
22+
enabled-checks:
23+
- hugeParam
24+
- rangeExprCopy
25+
- rangeValCopy
26+
- indexAlloc
27+
settings:
28+
ifElseChain:
29+
minThreshold: 3
30+
exclusions:
31+
generated: lax
32+
presets:
33+
- comments
34+
- common-false-positives
35+
- legacy
36+
- std-error-handling
37+
paths:
38+
- third_party$
39+
- builtin$
40+
- examples$
41+
rules:
42+
- linters:
43+
- staticcheck
44+
text: "QF1003:"
45+
- linters:
46+
- staticcheck
47+
text: "QF1008:"
48+
formatters:
49+
enable:
50+
- gofmt
51+
exclusions:
52+
generated: lax
53+
paths:
54+
- third_party$
55+
- builtin$
56+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG TARGETARCH
22

33
# Build the manager binary
4-
FROM docker.io/library/golang:1.23 as builder
4+
FROM docker.io/library/golang:1.24 as builder
55

66
ARG TARGETARCH=amd64
77
ARG LDFLAGS

Dockerfile.downstream

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG BUILDVERSION
22

33
# Build the manager binary
4-
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.23 as builder
4+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.24 as builder
55
ARG BUILDVERSION
66

77
WORKDIR /opt/app-root

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ BUNDLE_CONFIG ?= config/openshift-olm
7676
IMAGE ?= $(IMAGE_TAG_BASE):$(VERSION)
7777
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
7878
ENVTEST_K8S_VERSION = 1.23
79-
GOLANGCI_LINT_VERSION = v1.61.0
79+
GOLANGCI_LINT_VERSION = v2.2.1
8080

8181
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
8282
ifeq (,$(shell go env GOBIN))
@@ -314,7 +314,9 @@ clean-generated-conversions: ## Remove files generated by conversion-gen from th
314314
.PHONY: prereqs
315315
prereqs:
316316
@echo "### Test if prerequisites are met, and installing missing dependencies"
317-
GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
317+
test -f ./bin/golangci-lint-${GOLANGCI_LINT_VERSION} || ( \
318+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s ${GOLANGCI_LINT_VERSION} \
319+
&& mv ./bin/golangci-lint ./bin/golangci-lint-${GOLANGCI_LINT_VERSION})
318320

319321
.PHONY: vendors
320322
vendors: ## Refresh vendors directory.
@@ -327,7 +329,7 @@ fmt: ## Run go fmt against code.
327329
.PHONY: lint
328330
lint: prereqs ## Run linter (golangci-lint).
329331
@echo "### Linting code"
330-
golangci-lint run --timeout 5m ./...
332+
./bin/golangci-lint-${GOLANGCI_LINT_VERSION} run --timeout 5m ./...
331333

332334
test: envtest ## Run tests.
333335
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverpkg=./... -coverprofile cover.out

0 commit comments

Comments
 (0)