Skip to content

Commit f059a7a

Browse files
authored
build: Update all tools and fix up for golangci-lint v2 (#1108)
Reworked formatting to use `golangci-lint fmt` and applied formatting and linting changes to all files.
1 parent 2fbe024 commit f059a7a

26 files changed

+610
-633
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
- name: Export golang and golangci-lint versions
138138
id: versions
139139
run: |
140-
echo "golangci-lint=$(devbox run -- golangci-lint version --format short)" >>"${GITHUB_OUTPUT}"
140+
echo "golangci-lint=$(devbox run -- golangci-lint version --short)" >>"${GITHUB_OUTPUT}"
141141
echo "golang=$(devbox run -- go version | grep -o "[[:digit:]]\+.[[:digit:]]\+\(.[[:digit:]]\+\)\?")" >>"${GITHUB_OUTPUT}"
142142
143143
- name: golangci-lint

.golangci.yml

Lines changed: 98 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# Copyright 2021-2023 Nutanix. All rights reserved.
1+
# Copyright 2025 Nutanix. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
version: "2"
45
run:
5-
timeout: 10m
66
build-tags:
77
- e2e
8-
go: "1.23"
9-
108
linters:
11-
disable-all: true
9+
default: none
1210
enable:
1311
- containedctx
1412
- contextcheck
@@ -17,23 +15,19 @@ linters:
1715
- errchkjson
1816
- errname
1917
- gochecknoinits
20-
- gci
2118
- goconst
2219
- gocritic
2320
- gocyclo
2421
- godot
25-
- gofumpt
2622
- gosec
27-
- gosimple
2823
- govet
29-
- ineffassign
3024
- importas
25+
- ineffassign
3126
- lll
3227
- misspell
3328
- nolintlint
3429
- prealloc
3530
- staticcheck
36-
- stylecheck
3731
- testifylint
3832
- thelper
3933
- tparallel
@@ -42,84 +36,98 @@ linters:
4236
- unused
4337
- usetesting
4438
- whitespace
45-
46-
linters-settings:
47-
depguard:
39+
settings:
40+
depguard:
41+
rules:
42+
main:
43+
list-mode: lax
44+
deny:
45+
- pkg: k8s.io/kubernetes
46+
desc: do not use k8s.io/kubernetes directly
47+
- pkg: sigs.k8s.io/cluster-api-provider-
48+
desc: do not use CAPI providers directly, instead vendor necessary APIs
49+
- pkg: sigs.k8s.io/cluster-api-addon-provider-
50+
desc: do not use CAPI providers directly, instead vendor necessary APIs
51+
errcheck:
52+
exclude-functions:
53+
- encoding/json.Marshal
54+
- encoding/json.MarshalIndent
55+
errchkjson:
56+
check-error-free-encoding: true
57+
gocritic:
58+
enabled-tags:
59+
- diagnostic
60+
- experimental
61+
- opinionated
62+
- performance
63+
- style
64+
importas:
65+
alias:
66+
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
67+
alias: clusterv1
68+
no-unaliased: false
69+
lll:
70+
line-length: 120
71+
staticcheck:
72+
dot-import-whitelist:
73+
- github.com/onsi/ginkgo/v2
74+
- github.com/onsi/gomega
75+
testifylint:
76+
enable-all: true
77+
exclusions:
78+
generated: lax
79+
presets:
80+
- comments
81+
- common-false-positives
82+
- legacy
83+
- std-error-handling
4884
rules:
49-
main:
50-
list-mode: lax # Allow everything unless explicitly denied below.
51-
deny:
52-
- pkg: k8s.io/kubernetes
53-
desc: "do not use k8s.io/kubernetes directly"
54-
- pkg: sigs.k8s.io/cluster-api-provider-
55-
desc: "do not use CAPI providers directly, instead vendor necessary APIs"
56-
- pkg: sigs.k8s.io/cluster-api-addon-provider-
57-
desc: "do not use CAPI providers directly, instead vendor necessary APIs"
58-
errcheck:
59-
exclude-functions:
60-
- encoding/json.Marshal
61-
- encoding/json.MarshalIndent
62-
errchkjson:
63-
check-error-free-encoding: true
64-
gci:
65-
sections:
66-
- Standard
67-
- Default
68-
- Prefix(github.com/nutanix-cloud-native)
69-
- Prefix(github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix)
70-
gocritic:
71-
enabled-tags:
72-
- diagnostic
73-
- experimental
74-
- opinionated
75-
- performance
76-
- style
77-
gofumpt:
78-
extra-rules: true
79-
importas:
80-
no-unaliased: false
81-
alias:
82-
- pkg: "sigs.k8s.io/cluster-api/api/v1beta1"
83-
alias: clusterv1
84-
lll:
85-
line-length: 120
86-
stylecheck:
87-
# https://staticcheck.io/docs/configuration/options/#dot_import_whitelist
88-
dot-import-whitelist:
89-
- github.com/onsi/ginkgo/v2
90-
- github.com/onsi/gomega
91-
testifylint:
92-
enable-all: true
93-
94-
issues:
95-
exclude-dirs:
96-
# Although this is actually in api/external, api is a go module
97-
# and so need to specify the dir relative to the module root.
98-
- external
99-
exclude-rules:
100-
# ignore errcheck for flags.Parse (it is expected that we flag.ExitOnError)
101-
# ignore response.WriteError as it always returns the err it was passed
102-
- source: "flags.Parse|response.WriteError"
103-
linters:
104-
- errcheck
105-
- source: "// \\+kubebuilder:"
106-
linters:
107-
- lll
108-
# Idiomatic to use pass holderRef by value
109-
- text: "hugeParam: holderRef is heavy"
110-
linters:
111-
- gocritic
112-
# Admission request interface is defined by k8s
113-
- path: pkg/webhook
114-
text: "hugeParam: req is heavy"
115-
linters:
116-
- gocritic
117-
# This is not a problem in tests
118-
- path: internal/test/envtest
119-
text: "hugeParam: webhookInstallOptions is heavy"
120-
linters:
121-
- gocritic
122-
- path: internal/test/envtest
123-
text: "hugeParam: input is heavy"
124-
linters:
125-
- gocritic
85+
- linters:
86+
- errcheck
87+
source: flags.Parse|response.WriteError
88+
- linters:
89+
- lll
90+
source: '// \+kubebuilder:'
91+
- linters:
92+
- gocritic
93+
text: 'hugeParam: holderRef is heavy'
94+
- linters:
95+
- gocritic
96+
path: pkg/webhook
97+
text: 'hugeParam: req is heavy'
98+
- linters:
99+
- gocritic
100+
path: internal/test/envtest
101+
text: 'hugeParam: webhookInstallOptions is heavy'
102+
- linters:
103+
- gocritic
104+
path: internal/test/envtest
105+
text: 'hugeParam: input is heavy'
106+
paths:
107+
- external
108+
- third_party$
109+
- builtin$
110+
- examples$
111+
formatters:
112+
enable:
113+
- gci
114+
- gofumpt
115+
- golines
116+
settings:
117+
gci:
118+
sections:
119+
- Standard
120+
- Default
121+
- Prefix(github.com/nutanix-cloud-native)
122+
- Prefix(github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix)
123+
gofumpt:
124+
extra-rules: true
125+
golines:
126+
max-len: 120
127+
exclusions:
128+
generated: lax
129+
paths:
130+
- external
131+
- third_party$
132+
- builtin$
133+
- examples$

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: awsclusterconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_awsworkernodeconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: awsworkernodeconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: dockerclusterconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_dockerworkernodeconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: dockerworkernodeconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_genericclusterconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: genericclusterconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: nutanixclusterconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/crds/caren.nutanix.com_nutanixworkernodeconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apiVersion: apiextensions.k8s.io/v1
55
kind: CustomResourceDefinition
66
metadata:
77
annotations:
8-
controller-gen.kubebuilder.io/version: v0.17.2
8+
controller-gen.kubebuilder.io/version: v0.17.3
99
name: nutanixworkernodeconfigs.caren.nutanix.com
1010
spec:
1111
group: caren.nutanix.com

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)