Skip to content

Commit e491eee

Browse files
authored
Upgrade to Go 1.24 and golangci-lint v2 (#512)
* Upgrade to golangci-lint v2 * Build using Go 1.24 --------- Signed-off-by: Caleb Xu <[email protected]>
1 parent 7ce1ed1 commit e491eee

File tree

11 files changed

+87
-68
lines changed

11 files changed

+87
-68
lines changed

.golangci.yaml

Lines changed: 75 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,79 @@
1+
version: "2"
12
run:
2-
# Default timeout is 1m, up to give more room
3+
# Default timeout is 0 (no limit), have an upper limit
34
timeout: 4m
4-
5-
linters:
6-
enable:
7-
- asciicheck
8-
- unused
9-
- depguard
10-
- gofumpt
11-
- goimports
12-
- importas
13-
- revive
14-
- misspell
15-
- stylecheck
16-
- tparallel
17-
- unconvert
18-
- unparam
19-
- whitespace
20-
21-
linters-settings:
22-
importas:
23-
alias:
24-
- pkg: k8s.io/api/core/v1
25-
alias: corev1
26-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
27-
alias: metav1
28-
- pkg: k8s.io/apimachinery/pkg/api/errors
29-
alias: apierrors
30-
- pkg: github.com/operator-framework/api/pkg/operators/v1alpha1
31-
alias: operatorsv1alpha1
32-
- pkg: github.com/operator-framework/api/pkg/operators/v1
33-
alias: operatorsv1
34-
- pkg: github.com/openshift/api/image/v1
35-
alias: imagestreamv1
36-
revive:
37-
rules:
38-
- name: dot-imports
39-
severity: warning
40-
disabled: true
41-
stylecheck:
42-
dot-import-whitelist:
43-
- github.com/onsi/gomega
44-
- github.com/onsi/ginkgo
45-
- github.com/onsi/ginkgo/v2
46-
goimports:
47-
local-prefixes: github.com/redhat-certification/chart-verifier
48-
depguard:
49-
rules:
50-
main:
51-
list-mode: lax
52-
files:
53-
- !$test
54-
allow:
55-
- $gostd
56-
575
output:
586
formats:
59-
- format: tab
7+
tab:
8+
path: stdout
9+
colors: false
10+
linters:
11+
enable:
12+
- asciicheck
13+
- depguard
14+
- importas
15+
- misspell
16+
- revive
17+
- staticcheck
18+
- tparallel
19+
- unconvert
20+
- unparam
21+
- whitespace
22+
settings:
23+
depguard:
24+
rules:
25+
main:
26+
list-mode: lax
27+
files:
28+
- ""
29+
allow:
30+
- $gostd
31+
importas:
32+
alias:
33+
- pkg: k8s.io/api/core/v1
34+
alias: corev1
35+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
36+
alias: metav1
37+
- pkg: k8s.io/apimachinery/pkg/api/errors
38+
alias: apierrors
39+
- pkg: github.com/operator-framework/api/pkg/operators/v1alpha1
40+
alias: operatorsv1alpha1
41+
- pkg: github.com/operator-framework/api/pkg/operators/v1
42+
alias: operatorsv1
43+
- pkg: github.com/openshift/api/image/v1
44+
alias: imagestreamv1
45+
revive:
46+
rules:
47+
- name: dot-imports
48+
severity: warning
49+
disabled: true
50+
staticcheck:
51+
dot-import-whitelist:
52+
- github.com/onsi/gomega
53+
- github.com/onsi/ginkgo
54+
- github.com/onsi/ginkgo/v2
55+
exclusions:
56+
generated: lax
57+
presets:
58+
- comments
59+
- common-false-positives
60+
- legacy
61+
- std-error-handling
62+
paths:
63+
- third_party$
64+
- builtin$
65+
- examples$
66+
formatters:
67+
enable:
68+
- gofumpt
69+
- goimports
70+
settings:
71+
goimports:
72+
local-prefixes:
73+
- github.com/redhat-certification/chart-verifier
74+
exclusions:
75+
generated: lax
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/golang:1.23 as build
1+
FROM docker.io/golang:1.24 as build
22

33
WORKDIR /tmp/src
44

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ install.gofumpt:
158158

159159
# golangci-lint
160160
GOLANGCI_LINT = $(shell pwd)/out/golangci-lint
161-
GOLANGCI_LINT_VERSION ?= v1.63.4
161+
GOLANGCI_LINT_VERSION ?= v2.2.1
162162
install.golangci-lint: $(GOLANGCI_LINT)
163163
$(GOLANGCI_LINT):
164-
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))\
164+
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))\
165165

166166
# go-install-tool will 'go install' any package $2 and install it to $1.
167167
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/redhat-certification/chart-verifier
22

3-
go 1.23.5
3+
go 1.24.5
44

55
require (
66
dario.cat/mergo v1.0.1

internal/chartverifier/profiles/profile_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import (
1818
const (
1919
NoVersion string = ""
2020
configVersion00 string = "v0.0"
21-
//nolint:deadcode // TODO(komish) identify where this was intended to be used, or remove.
22-
// This should be unused but its triggering as deadcode which is replaced by the unused linter.
21+
// TODO(komish) identify where this was intended to be used, or remove.
2322
configVersion10 string = "v1.0"
2423
configVersion11 string = "v1.1"
2524
configVersion12 string = "v1.2"

internal/chartverifier/pyxis/pyxis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Loops:
222222
// when working with certified images or internal registries. Better to deal with this
223223
// by itself at a future date than introduce a potentially subtle bug.
224224
//
225-
//nolint:stylecheck
225+
//nolint:staticcheck // ST1005
226226
err = fmt.Errorf("No images found for Registry/Repository: %s/%s", registry, imageRef.Repository)
227227
}
228228
} else {

internal/chartverifier/verifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
func isOk(c *apiReport.Report) bool {
3636
outcome := true
3737
for _, check := range c.Results {
38-
if !(check.Outcome == apiReport.PassOutcomeType) {
38+
if check.Outcome != apiReport.PassOutcomeType {
3939
outcome = false
4040
break
4141
}

internal/helm/actions/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func RenderManifests(name string, url string, vals map[string]interface{}, conf
3838
}
3939
client.ReleaseName = name
4040

41-
cp, err := client.ChartPathOptions.LocateChart(chart, cli.New())
41+
cp, err := client.LocateChart(chart, cli.New())
4242
if err != nil {
4343
return emptyResponse, err
4444
}

internal/tool/helm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (h Helm) Install(ctx context.Context, namespace, chart, release, valuesFile
4949
// ref: https://helm.sh/docs/helm/helm_install
5050
client.Timeout = h.timeout
5151

52-
cp, err := client.ChartPathOptions.LocateChart(chart, h.envSettings)
52+
cp, err := client.LocateChart(chart, h.envSettings)
5353
if err != nil {
5454
utils.LogError(fmt.Sprintf("Error LocateChart: %v", err))
5555
return err
@@ -148,7 +148,7 @@ func (h Helm) Upgrade(ctx context.Context, namespace, chart, release string) err
148148
client.ReuseValues = true
149149
client.Wait = true
150150

151-
cp, err := client.ChartPathOptions.LocateChart(chart, h.envSettings)
151+
cp, err := client.LocateChart(chart, h.envSettings)
152152
if err != nil {
153153
utils.LogError(fmt.Sprintf("Error LocateChart: %v", err))
154154
return err

internal/tool/pgp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestDigest2(t *testing.T) {
3838
base64KeyFromCmd, _ := base64Cmd.Output()
3939

4040
base64Key := strings.Trim(string(base64KeyFromCmd), " -\n")
41-
base64Key = strings.Replace(base64Key, "\n", "", -1)
41+
base64Key = strings.ReplaceAll(base64Key, "\n", "")
4242

4343
encodedKey, encodeErr := GetEncodedKey(keyfileName)
4444
require.NoError(t, encodeErr)

0 commit comments

Comments
 (0)