-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy path.golangci.yml
More file actions
415 lines (378 loc) · 14.1 KB
/
Copy path.golangci.yml
File metadata and controls
415 lines (378 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
version: "2"
run:
timeout: 5m
formatters:
settings:
goimports:
# Put VMware imports beginning with the following prefixes after any
# third-party packages.
local-prefixes:
- github.com/vmware
- github.com/vmware-tanzu
- github.com/vmware-tanzu/vm-operator
linters:
default: all
disable:
- asasalint # 2
- containedctx # 3
- contextcheck # 50
- cyclop # 5
- dupl # 50
- dupword # 11
- err113 # 50
- errname # 6
- exhaustive # 29
- exhaustruct # 50
- exptostd # 2
- fatcontext # 3
- forbidigo # 1
- forcetypeassert # 6
- funcorder # 50
- funlen # 50
- ginkgolinter # 38
- gochecknoglobals # 50
- gochecknoinits # 3
- gocognit # 43
- godox # 50
- gomoddirectives # 9
- inamedparam # 11
- interfacebloat # 2
- intrange # 4
- ireturn # 50
- lll # 50
- loggercheck # 2
- maintidx # 26
- mirror # 2
- mnd # 50
- musttag # 3
- nestif # 50
- nilnil # 3
- nlreturn # 9
- noctx # 4
- nolintlint # 5
- nonamedreturns # 23
- nosprintfhostport # 3
- paralleltest # 50
- perfsprint # 7
- recvcheck # 5
- tagalign # 33
- tagliatelle # 8
- testpackage # 17
- thelper # 1
- usestdlibvars # 1
- varnamelen # 50
- whitespace # 6
- wrapcheck # 50
- wsl # 50
settings:
importas:
alias:
- alias: context
pkg: context
- alias: corev1
pkg: k8s.io/api/core/v1
- alias: metav1
pkg: k8s.io/apimachinery/pkg/apis/meta/v1
- alias: apiconversion
pkg: k8s.io/apimachinery/pkg/conversion
- alias: apierrors
pkg: k8s.io/apimachinery/pkg/api/errors
- alias: apierrorsutil
pkg: k8s.io/apimachinery/pkg/util/errors
- alias: ctrl
pkg: sigs.k8s.io/controller-runtime
- alias: ctrlcache
pkg: sigs.k8s.io/controller-runtime/pkg/cache
- alias: ctrlconversion
pkg: sigs.k8s.io/controller-runtime/pkg/conversion
- alias: ctrlclient
pkg: sigs.k8s.io/controller-runtime/pkg/client
- alias: ctrlmgr
pkg: sigs.k8s.io/controller-runtime/pkg/manager
- alias: vim25
pkg: github.com/vmware/govmomi/vim25
- alias: mo
pkg: github.com/vmware/govmomi/vim25/mo
- alias: pbmtypes
pkg: github.com/vmware/govmomi/pbm/types
- alias: vimtypes
pkg: github.com/vmware/govmomi/vim25/types
- alias: backupapi
pkg: github.com/vmware-tanzu/vm-operator/pkg/backup/api
- alias: vmopapi
pkg: github.com/vmware-tanzu/vm-operator/api
- alias: vmopv1a1
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha1
- alias: vmopv1a2
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha2
- alias: vmopv1a2cloudinit
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha2/cloudinit
- alias: vmopv1a2common
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha2/common
- alias: vmopv1a2sysprep
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha2/sysprep
- alias: vmopv1a3
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha3
- alias: vmopv1a3cloudinit
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha3/cloudinit
- alias: vmopv1a3common
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha3/common
- alias: vmopv1a3sysprep
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha3/sysprep
- alias: vmopv1a4
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha4
- alias: vmopv1a4cloudinit
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha4/cloudinit
- alias: vmopv1a4common
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha4/common
- alias: vmopv1a4sysprep
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha4/sysprep
- alias: vmopv1a5
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha5
- alias: vmopv1a5cloudinit
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha5/cloudinit
- alias: vmopv1a5common
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha5/common
- alias: vmopv1a5sysprep
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha5/sysprep
- alias: vmopv1
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha6
- alias: vmopv1cloudinit
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha6/cloudinit
- alias: vmopv1common
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha6/common
- alias: vmopv1sysprep
pkg: github.com/vmware-tanzu/vm-operator/api/v1alpha6/sysprep
- alias: vmopv1util
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1
- alias: byokv1
pkg: github.com/vmware-tanzu/vm-operator/external/byok/api/v1alpha1
- alias: capv1
pkg: github.com/vmware-tanzu/vm-operator/external/capabilities/api/v1alpha1
- alias: appv1a1
pkg: github.com/vmware-tanzu/vm-operator/external/appplatform/api/v1alpha1
- alias: vspherepolv1
pkg: github.com/vmware-tanzu/vm-operator/external/vsphere-policy/api/v1alpha1
- alias: infrav1
pkg: github.com/vmware-tanzu/vm-operator/external/infra/api/v1alpha1
- alias: vimv1
pkg: github.com/vmware-tanzu/vm-operator/external/vim/api/v1alpha1
- alias: proxyaddr
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/kube/proxyaddr
- alias: pkgcrd
pkg: github.com/vmware-tanzu/vm-operator/pkg/crd
- alias: pkgcfg
pkg: github.com/vmware-tanzu/vm-operator/pkg/config
- alias: pkgcond
pkg: github.com/vmware-tanzu/vm-operator/pkg/conditions
- alias: pkgconst
pkg: github.com/vmware-tanzu/vm-operator/pkg/constants
- alias: pkgctx
pkg: github.com/vmware-tanzu/vm-operator/pkg/context
- alias: pkgerr
pkg: github.com/vmware-tanzu/vm-operator/pkg/errors
- alias: pkgexit
pkg: github.com/vmware-tanzu/vm-operator/pkg/exit
- alias: pkglog
pkg: github.com/vmware-tanzu/vm-operator/pkg/log
- alias: pkgnil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/nil
- alias: ctxop
pkg: github.com/vmware-tanzu/vm-operator/pkg/context/operation
- alias: pkgmgr
pkg: github.com/vmware-tanzu/vm-operator/pkg/manager
- alias: pkgutil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util
- alias: proberctx
pkg: github.com/vmware-tanzu/vm-operator/pkg/prober/context
- alias: clsutil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/library
- alias: kubeutil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/kube
depguard:
rules:
main:
list-mode: lax # allow unless explicitly denied
files:
- $all
- "!$test"
- "!**/test/builder/*.go"
- "!**/test/builder/log/*.go"
- "!**/matcher.go"
- "!**/pkg/util/kube/storage.go"
allow:
- $gostd
- github.com/go-logr/logr
- sigs.k8s.io/controller-runtime
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- pkg: github.com/pkg/errors
desc: "replaced by stdlib errors package since Go.13: https://go.dev/blog/go1.13-errors"
- pkg: k8s.io/utils
desc: "replaced by internal packages like pkg/util/ptr"
- pkg: testing
desc: "do not import testing packages in non-test sources"
- pkg: github.com/onsi/ginkgo$
desc: "do not import testing packages in non-test sources"
- pkg: github.com/onsi/ginkgo/v2
desc: "do not import testing packages in non-test sources"
- pkg: github.com/onsi/gomega
desc: "do not import testing packages in non-test sources"
#
# This section is a duplicate of the main section, so please keep their
# rules in lock-step. However, the one difference is files matched by
# this section are allowed to import the "testing" package in order for
# something in the file to determine if the code is being executed as
# part of a test or not.
#
allow-testing-import:
list-mode: lax # allow unless explicitly denied
files:
- "**/pkg/util/kube/storage.go"
allow:
- $gostd
- github.com/go-logr/logr
- sigs.k8s.io/controller-runtime
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- pkg: github.com/pkg/errors
desc: "replaced by stdlib errors package since Go.13: https://go.dev/blog/go1.13-errors"
- pkg: k8s.io/utils
desc: "replaced by internal packages like pkg/util/ptr"
- pkg: github.com/onsi/ginkgo$
desc: "do not import testing packages in non-test sources"
- pkg: github.com/onsi/ginkgo/v2
desc: "do not import testing packages in non-test sources"
- pkg: github.com/onsi/gomega
desc: "do not import testing packages in non-test sources"
test:
list-mode: lax # allow unless explicitly denied
files:
- $test
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- pkg: github.com/pkg/errors
desc: "replaced by stdlib errors package since Go.13: https://go.dev/blog/go1.13-errors"
- pkg: k8s.io/utils
desc: "replaced by internal packages like pkg/util/ptr"
- pkg: github.com/onsi/ginkgo$
desc: "replaced by github.com/onsi/ginkgo/v2"
test-builder:
list-mode: lax # allow unless explicitly denied
files:
- "**/test/builder/*.go"
- "**/matcher.go"
- "!$test"
deny:
- pkg: io/ioutil
desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil"
- pkg: github.com/pkg/errors
desc: "replaced by stdlib errors package since Go.13: https://go.dev/blog/go1.13-errors"
- pkg: k8s.io/utils
desc: "replaced by internal packages like pkg/util/ptr"
- pkg: github.com/onsi/ginkgo$
desc: "replaced by github.com/onsi/ginkgo/v2"
exclusions:
generated: lax
warn-unused: true
paths:
- external
- pkg/util/cloudinit/schema
- pkg/util/netplan/schema
- ".*generated.*\\.go"
rules:
# TODO: Stop excluding ST1000 once the issue has been resolved.
- linters:
- golint
text: "ST1000: at least one file in a package should have a package comment"
- linters:
- staticcheck
text: "^SA1019: corev1.(Endpoints|EndpointSubset) is deprecated: This API is deprecated in v1.33+.*"
- linters:
- staticcheck
text: "^SA1019: [^.]+.Wait is deprecated: Please use WaitEx instead."
- linters:
- staticcheck
text: "^SA1019: [^.]+.WaitForResult is deprecated: Please use WaitForResultEx instead."
- linters:
- staticcheck
text: "^SA1019: .*TCPSocket is deprecated"
- linters:
- staticcheck
text: "^SA1019: c?vmiAfter.Status.ContentLibraryRef is deprecated"
- linters:
- staticcheck
text: "QF1008: could remove embedded field"
- linters:
- staticcheck
text: "QF1003: could use tagged switch"
- linters:
- revive
text: ".*should have (a package )?comment.*"
- linters:
- revive
text: "^exported: comment on exported const"
- linters:
- revive
text: "unused-parameter: parameter"
- linters:
- govet
text: "printf: non-constant format string in call"
# Dot imports for gomega or ginkgo are allowed within test files.
- path: test/builder/intg_test_context.go
text: should not use dot imports
- path: test/builder/test_suite.go
text: should not use dot imports
- path: test/builder/vcsim_test_context.go
text: should not use dot imports
- path: _test.go
text: should not use dot imports
# All of our webhooks follow the pattern of passing the webhook context
# which contains fields like the Client. Ignore the linter warnings for now.
- path: webhooks/
text: ".* ctx is unused"
linters:
- unparam
- path: _test.go
linters:
- depguard
- gosec
- path: pkg/config/env/env.go
linters:
- gocyclo
- path: pkg/providers/vsphere/vmlifecycle/update_status.go
linters:
- gocyclo
# Ignore underscores in conversion function names as required by K8s API.
- path: "_conversion.go"
text: ".*use underscores in Go names"
# Ignore unsafe.Pointer() calls used in conversion functions.
- path: "_conversion.go"
text: "G103: Use of unsafe calls should be audited"
# Ignore different receiver names in conversion functions (e.g. src vs dst).
- path: "_conversion.go"
text: ".*receiver name"
- path: "test/e2e"
linters:
- revive
- gosec
- prealloc
- wsl
- wsl_v5
- gocritic
- gocyclo
- noinlineerr
- makezero
- modernize
- gocheckcompilerdirectives
- embeddedstructcheck
- importas
- ineffassign
- goconst
- depguard
- godoclint
# E2E tests use . imports for gomega or ginkgo.
- staticcheck