Skip to content

Commit ac8e35b

Browse files
Update go to 1.25.1, gomega, pflag, ginkgo, testify and migrate to golangci-lint v2
1 parent e223488 commit ac8e35b

File tree

16 files changed

+665
-614
lines changed

16 files changed

+665
-614
lines changed

.golangci.yml

Lines changed: 162 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
version: "2"
2+
run:
3+
build-tags:
4+
- e2e
5+
allow-parallel-runners: true
16
linters:
2-
disable-all: true
7+
default: none
38
enable:
49
- asciicheck
510
- bidichk
@@ -13,14 +18,11 @@ linters:
1318
- errname
1419
- errorlint
1520
- exhaustive
16-
- gci
1721
- ginkgolinter
1822
- goconst
1923
- gocritic
2024
- godot
21-
- gofumpt
2225
- gosec
23-
- gosimple
2426
- govet
2527
- importas
2628
- inamedparam
@@ -34,175 +36,171 @@ linters:
3436
- nilerr
3537
- nolintlint
3638
- nosprintfhostport
37-
- prealloc
3839
- perfsprint
39-
- revive
40+
- prealloc
4041
- reassign
42+
- revive
4143
- staticcheck
42-
- stylecheck
4344
- tagalign
4445
- testifylint
45-
- tenv
46-
- typecheck
4746
- unconvert
4847
- unparam
4948
- unused
5049
- whitespace
51-
52-
linters-settings:
53-
depguard:
50+
settings:
51+
depguard:
52+
rules:
53+
main:
54+
deny:
55+
- pkg: github.com/pkg/errors
56+
desc: Should be replaced by stdlib errors package
57+
gosec:
58+
excludes:
59+
- G601
60+
importas:
61+
alias:
62+
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
63+
alias: $1$2
64+
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
65+
alias: apiextensionsv1
66+
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
67+
alias: metav1
68+
- pkg: k8s.io/apimachinery/pkg/api/errors
69+
alias: apierrors
70+
- pkg: k8s.io/apimachinery/pkg/util/errors
71+
alias: kerrors
72+
- pkg: sigs.k8s.io/controller-runtime
73+
alias: ctrl
74+
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
75+
alias: clusterv1
76+
- pkg: sigs.k8s.io/cluster-api/test/e2e
77+
alias: capie2e
78+
- pkg: github.com/ionos-cloud/cluster-api-provider-ionoscloud/api/v1alpha1
79+
alias: infrav1
80+
- pkg: github.com/ionos-cloud/sdk-go/v6
81+
alias: sdk
82+
no-unaliased: true
83+
ireturn:
84+
allow:
85+
- error
86+
- generic
87+
- ionoscloud.Client
88+
- bootstrap.ClusterProvider
89+
- framework.ClusterProxy
90+
loggercheck:
91+
require-string-key: true
92+
no-printf-like: true
93+
revive:
94+
enable-all-rules: true
95+
rules:
96+
- name: add-constant
97+
disabled: true
98+
- name: enforce-switch-style
99+
disabled: true
100+
- name: cognitive-complexity
101+
arguments:
102+
- 25
103+
- name: cyclomatic
104+
arguments:
105+
- 15
106+
- name: line-length-limit
107+
disabled: true
108+
- name: max-public-structs
109+
disabled: true
110+
- name: range-val-address
111+
disabled: true
112+
- name: struct-tag
113+
arguments:
114+
- json,inline
115+
- name: var-naming
116+
arguments:
117+
- []
118+
- - LAN
119+
- IP
120+
- NIC
121+
testifylint:
122+
enable-all: true
123+
exclusions:
124+
generated: lax
54125
rules:
55-
main:
56-
deny:
57-
- pkg: "github.com/pkg/errors"
58-
desc: Should be replaced by stdlib errors package
59-
gci:
60-
sections:
61-
- standard
62-
- default
63-
- prefix(github.com/ionos-cloud/cluster-api-provider-ionoscloud)
64-
- blank
65-
- dot
66-
gosec:
67-
excludes:
68-
- G601 # Implicit memory aliasing of items from a range statement: Obsolete since Go 1.22
69-
importas:
70-
no-unaliased: true
71-
alias:
72-
# Kubernetes
73-
- pkg: k8s.io/api/(\w+)/(v[\w\d]+)
74-
alias: $1$2
75-
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
76-
alias: apiextensionsv1
77-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
78-
alias: metav1
79-
- pkg: k8s.io/apimachinery/pkg/api/errors
80-
alias: apierrors
81-
- pkg: k8s.io/apimachinery/pkg/util/errors
82-
alias: kerrors
83-
# Controller Runtime
84-
- pkg: sigs.k8s.io/controller-runtime
85-
alias: ctrl
86-
# Cluster API
87-
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
88-
alias: clusterv1
89-
- pkg: "sigs.k8s.io/cluster-api/test/e2e"
90-
alias: capie2e
91-
# Own module
92-
- pkg: github.com/ionos-cloud/cluster-api-provider-ionoscloud/api/v1alpha1
93-
alias: infrav1
94-
- pkg: github.com/ionos-cloud/sdk-go/v6
95-
alias: sdk
96-
ireturn:
97-
allow:
98-
- error
99-
- generic
100-
- ionoscloud.Client
101-
- bootstrap.ClusterProvider
102-
- framework.ClusterProxy
103-
loggercheck:
104-
require-string-key: true
105-
no-printf-like: true
106-
revive:
107-
enable-all-rules: true
108-
rules:
109-
- name: add-constant
110-
disabled: true
111-
- name: cognitive-complexity
112-
arguments:
113-
- 25
114-
- name: cyclomatic
115-
arguments:
116-
- 15
117-
- name: line-length-limit
118-
disabled: true
119-
- name: max-public-structs
120-
disabled: true
121-
- name: range-val-address
122-
disabled: true # Obsolete since Go 1.22
123-
- name: struct-tag
124-
arguments:
125-
- json,inline
126-
- name: var-naming
127-
arguments:
128-
- [] # first list is an allow list. All initialisms placed here will be ignored
129-
- [LAN, IP, NIC] # second list is a deny list. These rules will be enforced
130-
testifylint:
131-
enable-all: true
132-
126+
- linters:
127+
- containedctx
128+
path: (.+)_test\.go
129+
- linters:
130+
- gocritic
131+
text: 'appendAssign: append result not assigned to the same slice'
132+
- linters:
133+
- revive
134+
text: 'comment-spacings: no space between comment delimiter and comment text'
135+
source: //(\+(kubebuilder|optional|required)|#nosec)
136+
- linters:
137+
- revive
138+
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'
139+
- linters:
140+
- revive
141+
path: suite_test.go
142+
text: maximum number of lines per function exceeded
143+
- linters:
144+
- revive
145+
text: exported (method|function|type|const) (.+) should have comment or be unexported
146+
source: (func|type).*Fake.*
147+
- linters:
148+
- revive
149+
path: fake_\.go
150+
text: exported (method|function|type|const) (.+) should have comment or be unexported
151+
- linters:
152+
- revive
153+
path: (framework|e2e|infrastructure/docker)/.*.go
154+
text: exported (method|function|type|const) (.+) should have comment or be unexported
155+
- linters:
156+
- revive
157+
text: line is \d+ characters, out of limit \d+
158+
source: \s*//\+kubebuilder:.*
159+
- linters:
160+
- revive
161+
text: line is \d+ characters, out of limit \d+
162+
source: \s*//.*[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?$
163+
- linters:
164+
- revive
165+
path: _test\.go
166+
text: 'function-length: maximum number of lines per function exceeded'
167+
- linters:
168+
- unparam
169+
text: always receives
170+
- path: _test\.go
171+
text: should not use dot imports
172+
- path: _test\.go
173+
text: cyclomatic complexity
174+
- path: (framework|e2e)/.*.go
175+
text: should not use dot imports
176+
paths:
177+
- zz_generated.*\.go$
178+
- .*conversion.*\.go$
179+
- mock*
180+
- third_party$
181+
- builtin$
182+
- examples$
133183
issues:
134-
max-same-issues: 0
135184
max-issues-per-linter: 0
136-
# We are disabling default golangci exclusions because we want to help reviewers to focus on reviewing the most relevant
137-
# changes in PRs and avoid nitpicking.
138-
exclude-use-default: false
139-
exclude-rules:
140-
- linters:
141-
- containedctx
142-
path: '(.+)_test\.go'
143-
- linters:
144-
- gocritic
145-
text: "appendAssign: append result not assigned to the same slice"
146-
- linters:
147-
- revive
148-
text: "comment-spacings: no space between comment delimiter and comment text"
149-
source: "//(\\+(kubebuilder|optional|required)|#nosec)"
150-
- linters:
151-
- revive
152-
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"
153-
- linters:
154-
- revive
155-
text: maximum number of lines per function exceeded
156-
path: suite_test.go
157-
# Exclude some packages or code to require comments, for example test code, or fake clients.
158-
- linters:
159-
- revive
160-
text: exported (method|function|type|const) (.+) should have comment or be unexported
161-
source: (func|type).*Fake.*
162-
- linters:
163-
- revive
164-
text: exported (method|function|type|const) (.+) should have comment or be unexported
165-
path: fake_\.go
166-
- linters:
167-
- revive
168-
text: exported (method|function|type|const) (.+) should have comment or be unexported
169-
path: "(framework|e2e|infrastructure/docker)/.*.go"
170-
- linters:
171-
- revive
172-
text: "line is \\d+ characters, out of limit \\d+"
173-
source: "\\s*//\\+kubebuilder:.*"
174-
- linters:
175-
- revive
176-
text: "line is \\d+ characters, out of limit \\d+"
177-
# If a line comment ends with something that looks like a URL, we ignore the line length limit.
178-
source: "\\s*//.*[-a-zA-Z0-9@:%_\\+.~#?&//=]{2,256}\\.[a-z]{2,4}\\b(\\/[-a-zA-Z0-9@:%_\\+.~#?&//=]*)?$"
179-
- linters:
180-
- revive
181-
text: "function-length: maximum number of lines per function exceeded"
182-
path: _test\.go
183-
# Disable unparam "always receives" which might not be really
184-
# useful when building libraries.
185-
- linters:
186-
- unparam
187-
text: always receives
188-
# Dot imports for gomega or ginkgo are allowed
189-
# within test files.
190-
- path: _test\.go
191-
text: should not use dot imports
192-
- path: _test\.go
193-
text: cyclomatic complexity
194-
# Append should be able to assign to a different var/slice.
195-
- path: (framework|e2e)/.*.go
196-
text: should not use dot imports
197-
exclude-files:
198-
- "zz_generated.*\\.go$"
199-
- ".*conversion.*\\.go$"
200-
exclude-dirs:
201-
- mock*
202-
203-
run:
204-
build-tags:
205-
- e2e
206-
timeout: 10m
207-
allow-parallel-runners: true
208-
go: "1.22"
185+
max-same-issues: 0
186+
formatters:
187+
enable:
188+
- gci
189+
- gofumpt
190+
settings:
191+
gci:
192+
sections:
193+
- standard
194+
- default
195+
- prefix(github.com/ionos-cloud/cluster-api-provider-ionoscloud)
196+
- blank
197+
- dot
198+
exclusions:
199+
generated: lax
200+
paths:
201+
- zz_generated.*\.go$
202+
- .*conversion.*\.go$
203+
- mock*
204+
- third_party$
205+
- builtin$
206+
- examples$

0 commit comments

Comments
 (0)