Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit dc74571

Browse files
authored
Merge pull request #661 from cprivitere/capi-1.4
✨ Update to 1.4 CAPI
2 parents 437f509 + 5cbb85d commit dc74571

38 files changed

+737
-487
lines changed

.golangci.yml

Lines changed: 295 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,99 @@
1+
run:
2+
timeout: 10m
3+
go: "1.20"
4+
build-tags:
5+
- tools
6+
- e2e
7+
skip-files:
8+
- "zz_generated.*\\.go$"
9+
- "vendored_openapi\\.go$"
10+
allow-parallel-runners: true
11+
112
linters:
2-
enable-all: true
3-
disable:
4-
- cyclop
5-
- deadcode
6-
- errname
7-
- exhaustive
8-
- exhaustruct
9-
- exhaustivestruct
10-
- forbidigo
11-
- funlen
12-
- gci
13-
- gochecknoglobals
14-
- gochecknoinits
15-
- gocognit
13+
disable-all: true
14+
enable:
15+
- asasalint
16+
- asciicheck
17+
- bidichk
18+
- bodyclose
19+
- containedctx
20+
- dogsled
21+
- dupword
22+
- durationcheck
23+
- errcheck
24+
- errchkjson
25+
- exportloopref
26+
- ginkgolinter
27+
- goconst
28+
- gocritic
1629
- godot
17-
- godox
18-
- golint
19-
- gofumpt
20-
- gomnd
21-
- ifshort
22-
- interfacer
23-
- lll
24-
- maligned
25-
- nestif
26-
- nilnil
27-
- nlreturn
28-
- nosnakecase
29-
- paralleltest
30-
- scopelint
31-
- structcheck
32-
- tagliatelle
33-
- testpackage
30+
- gofmt
31+
- goimports
32+
- goprintffuncname
33+
- gosec
34+
- gosimple
35+
- govet
36+
- importas
37+
- ineffassign
38+
- misspell
39+
- nakedret
40+
- nilerr
41+
- noctx
42+
- nolintlint
43+
- nosprintfhostport
44+
- prealloc
45+
- predeclared
46+
- revive
47+
- rowserrcheck
48+
- staticcheck
49+
- stylecheck
3450
- thelper
35-
- tparallel
36-
- varcheck
37-
- varnamelen
38-
- wrapcheck
39-
- wsl
51+
- typecheck
52+
- unconvert
53+
- unparam
54+
- unused
55+
- usestdlibvars
56+
- whitespace
4057

4158
linters-settings:
59+
gci:
60+
sections:
61+
- standard
62+
- default
63+
- prefix(sigs.k8s.io/cluster-api-provider-packet)
64+
custom-order: true
65+
ginkgolinter:
66+
forbid-focus-container: true
67+
godot:
68+
# declarations - for top level declaration comments (default);
69+
# toplevel - for top level comments;
70+
# all - for all comments.
71+
scope: toplevel
72+
exclude:
73+
- '^ \+.*'
74+
- "^ ANCHOR.*"
75+
gocritic:
76+
enabled-tags:
77+
- diagnostic
78+
- experimental
79+
- performance
80+
disabled-checks:
81+
- appendAssign
82+
- dupImport # https://github.com/go-critic/go-critic/issues/845
83+
- evalOrder
84+
- ifElseChain
85+
- octalLiteral
86+
- regexpSimplify
87+
- sloppyReassign
88+
- truncateCmp
89+
- typeDefFirst
90+
- unnamedResult
91+
- unnecessaryDefer
92+
- whyNoLint
93+
- wrapperFunc
94+
- rangeValCopy
95+
- hugeParam
4296
importas:
43-
# Do not allow unaliased imports of aliased packages.
44-
# Default: false
4597
no-unaliased: true
4698
alias:
4799
# Kubernetes
@@ -55,37 +107,217 @@ linters-settings:
55107
alias: apierrors
56108
- pkg: k8s.io/apimachinery/pkg/util/errors
57109
alias: kerrors
110+
- pkg: k8s.io/component-base/logs/api/v1
111+
alias: logsv1
58112
# Controller Runtime
59113
- pkg: sigs.k8s.io/controller-runtime
60114
alias: ctrl
61-
tagliatelle:
62-
case:
63-
rules:
64-
# Any struct tag type can be used.
65-
# Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header`
66-
json: goCamel
67-
gomoddirectives:
68-
# List of allowed `replace` directives.
69-
# Default: []
70-
replace-allow-list:
71-
- sigs.k8s.io/cluster-api
72-
goimports:
73-
# put imports beginning with prefix after 3rd-party packages;
74-
# it's a comma-separated list of prefixes
75-
local-prefixes: sigs.k8s.io/cluster-api-provider-packet
115+
# CABPK
116+
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1alpha4
117+
alias: bootstrapv1alpha4
118+
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
119+
alias: bootstrapv1
120+
# KCP
121+
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1alpha4
122+
alias: controlplanev1alpha4
123+
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
124+
alias: controlplanev1
125+
# CAPI
126+
- pkg: sigs.k8s.io/cluster-api/api/v1alpha4
127+
alias: clusterv1alpha4
128+
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
129+
alias: clusterv1
130+
# CAPI exp
131+
- pkg: sigs.k8s.io/cluster-api/exp/api/v1alpha4
132+
alias: expv1alpha4
133+
- pkg: sigs.k8s.io/cluster-api/exp/api/v1beta1
134+
alias: expv1
135+
# CAPI exp addons
136+
- pkg: sigs.k8s.io/cluster-api/exp/addons/api/v1alpha4
137+
alias: addonsv1alpha4
138+
- pkg: sigs.k8s.io/cluster-api/exp/addons/api/v1beta1
139+
alias: addonsv1
140+
# CAPI exp runtime
141+
- pkg: sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1
142+
alias: runtimev1
143+
- pkg: sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1
144+
alias: runtimehooksv1
145+
- pkg: sigs.k8s.io/cluster-api/exp/runtime/controllers
146+
alias: runtimecontrollers
147+
- pkg: sigs.k8s.io/cluster-api/exp/runtime/catalog
148+
alias: runtimecatalog
149+
- pkg: sigs.k8s.io/cluster-api/internal/runtime/client
150+
alias: runtimeclient
151+
- pkg: sigs.k8s.io/cluster-api/internal/runtime/registry
152+
alias: runtimeregistry
153+
- pkg: sigs.k8s.io/cluster-api/internal/webhooks/runtime
154+
alias: runtimewebhooks
155+
# CAPD
156+
- pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha4
157+
alias: infrav1alpha4
158+
- pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1
159+
alias: infrav1
160+
# CAPD exp
161+
- pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1alpha4
162+
alias: infraexpv1alpha4
163+
- pkg: sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1
164+
alias: infraexpv1
76165
nolintlint:
77-
# Enable to require nolint directives to mention the specific linter being suppressed.
78-
# Default: false
166+
allow-unused: false
167+
allow-leading-space: false
79168
require-specific: true
80169
revive:
81170
rules:
171+
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
172+
- name: blank-imports
173+
- name: context-as-argument
174+
- name: context-keys-type
175+
- name: dot-imports
176+
- name: error-return
177+
- name: error-strings
178+
- name: error-naming
179+
- name: exported
180+
- name: if-return
181+
- name: increment-decrement
182+
- name: var-naming
183+
- name: var-declaration
184+
- name: package-comments
185+
- name: range
186+
- name: time-naming
187+
- name: unexported-return
188+
- name: indent-error-flow
189+
- name: errorf
190+
- name: empty-block
191+
- name: superfluous-else
82192
- name: unused-parameter
83-
disabled: true
193+
- name: unreachable-code
194+
- name: redefines-builtin-id
195+
#
196+
# Rules in addition to the recommended configuration above.
197+
#
198+
- name: bool-literal-in-expr
199+
- name: constant-logical-expr
84200

85-
run:
86-
go: '1.19'
87-
timeout: 10m
88-
skip-files:
89-
- "zz_generated.*\\.go$"
90-
- ".*conversion.*\\.go$"
91-
allow-parallel-runners: true
201+
issues:
202+
max-same-issues: 0
203+
max-issues-per-linter: 0
204+
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant
205+
# changes in PRs and avoid nitpicking.
206+
exclude-use-default: false
207+
exclude-rules:
208+
- path: api/v1alpha3
209+
linters:
210+
- revive
211+
- gosec
212+
- stylecheck
213+
# Specific exclude rules for deprecated fields that are still part of the codebase. These
214+
# should be removed as the referenced deprecated item is removed from the project.
215+
- linters:
216+
- staticcheck
217+
text: "SA1019: (noderefutil.*|parsed.*) is deprecated"
218+
# Specific exclude rules for deprecated fields that are still part of the codebase. These
219+
# should be removed as the referenced deprecated item is removed from the project.
220+
- linters:
221+
- staticcheck
222+
text: "SA1019: (bootstrapv1.ClusterStatus|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped) is deprecated"
223+
# Specific exclude rules for deprecated packages that are still part of the codebase. These
224+
# should be removed as the referenced deprecated packages are removed from the project.
225+
- linters:
226+
- staticcheck
227+
text: "SA1019: .* is deprecated: This package will be removed in one of the next releases."
228+
# Specific exclude rules for deprecated types that are still part of the codebase. These
229+
# should be removed as the referenced deprecated types are removed from the project.
230+
- linters:
231+
- staticcheck
232+
text: "SA1019: (clusterv1alpha4.*) is deprecated: This type will be removed in one of the next releases."
233+
- linters:
234+
- revive
235+
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"
236+
- linters:
237+
- errcheck
238+
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
239+
# Exclude some packages or code to require comments, for example test code, or fake clients.
240+
- linters:
241+
- revive
242+
text: exported (method|function|type|const) (.+) should have comment or be unexported
243+
source: (func|type).*Fake.*
244+
- linters:
245+
- revive
246+
text: exported (method|function|type|const) (.+) should have comment or be unexported
247+
path: fake_\.go
248+
- linters:
249+
- revive
250+
text: exported (method|function|type|const) (.+) should have comment or be unexported
251+
path: cmd/clusterctl/internal/test/providers.*.go
252+
- linters:
253+
- revive
254+
text: exported (method|function|type|const) (.+) should have comment or be unexported
255+
path: "(framework|e2e)/.*.go"
256+
# Disable unparam "always receives" which might not be really
257+
# useful when building libraries.
258+
- linters:
259+
- unparam
260+
text: always receives
261+
# Dot imports for gomega and ginkgo are allowed
262+
# within test files and test utils.
263+
- linters:
264+
- revive
265+
- stylecheck
266+
path: _test\.go
267+
text: should not use dot imports
268+
- linters:
269+
- revive
270+
- stylecheck
271+
path: (framework|e2e)/.*.go
272+
text: should not use dot imports
273+
- linters:
274+
- revive
275+
- stylecheck
276+
path: util/defaulting/defaulting.go
277+
text: should not use dot imports
278+
# Append should be able to assign to a different var/slice.
279+
- linters:
280+
- gocritic
281+
text: "appendAssign: append result not assigned to the same slice"
282+
# Disable linters for conversion
283+
- linters:
284+
- staticcheck
285+
text: "SA1019: in.(.+) is deprecated"
286+
path: .*(api|types)\/.*\/conversion.*\.go$
287+
- linters:
288+
- revive
289+
# Checking if an error is nil to just after return the error or nil is redundant
290+
text: "if-return: redundant if ...; err != nil check, just return error instead"
291+
# Ignoring stylistic checks for generated code
292+
path: .*(api|types|test)\/.*\/conversion.*\.go$
293+
- linters:
294+
- revive
295+
# Exported function and methods should have comments. This warns on undocumented exported functions and methods.
296+
text: exported (method|function|type|const) (.+) should have comment or be unexported
297+
# Ignoring stylistic checks for generated code
298+
path: .*(api|types|test)\/.*\/conversion.*\.go$
299+
- linters:
300+
- revive
301+
# This rule warns when initialism, variable or package naming conventions are not followed.
302+
text: "var-naming: don't use underscores in Go names;"
303+
# Ignoring stylistic checks for generated code
304+
path: .*(api|types|test)\/.*\/conversion.*\.go$
305+
- linters:
306+
- revive
307+
# By convention, receiver names in a method should reflect their identity.
308+
text: "receiver-naming: receiver name"
309+
# Ignoring stylistic checks for generated code
310+
path: .*(api|types)\/.*\/conversion.*\.go$
311+
- linters:
312+
- stylecheck
313+
text: "ST1003: should not use underscores in Go names;"
314+
path: .*(api|types|test)\/.*\/conversion.*\.go$
315+
- linters:
316+
- stylecheck
317+
text: "ST1016: methods on the same type should have the same receiver name"
318+
path: .*(api|types)\/.*\/conversion.*\.go$
319+
# We don't care about defer in for loops in test files.
320+
- linters:
321+
- gocritic
322+
text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop"
323+
path: _test\.go

0 commit comments

Comments
 (0)