-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy path.golangci-kube-api.yaml
More file actions
135 lines (128 loc) · 5.06 KB
/
.golangci-kube-api.yaml
File metadata and controls
135 lines (128 loc) · 5.06 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
version: "2"
go: "1.26"
linters:
default: none
enable:
- kubeapilinter
settings:
custom:
kubeapilinter:
type: module
description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
settings:
linters:
disable:
- "*"
enable:
- arrayofstruct
- conditions
- defaultorrequired
- duplicatemarkers
- integers
- jsontags
- maxlength
- nobools
- nodurations
- nofloats
- nomaps
- nonullable
- nophase
- notimestamp
- optionalorrequired
- preferredmarkers
- requiredfields
- statusoptional
- statussubresource
- uniquemarkers
lintersConfig:
# https://github.com/kubernetes-sigs/kube-api-linter/issues/195
# requiredfields:
# omitempty:
# policy: Ignore
preferredmarkers:
markers:
- preferredIdentifier: "k8s:optional"
equivalentIdentifiers:
- identifier: "kubebuilder:validation:Optional"
- preferredIdentifier: "k8s:required"
equivalentIdentifiers:
- identifier: "kubebuilder:validation:Required"
conditions:
isFirstField: Warn
useProtobuf: Warn
usePatchStrategy: Warn
nomaps:
policy: AllowStringToStringMaps
# We allow underscores as that's what many Konnect related fields use.
jsonTags:
jsonTagRegex: "^[a-z][a-z0-9_]*(?:[A-Z][a-z0-9_]*)*$"
optionalOrRequired:
preferredOptionalMarker: optional
preferredRequiredMarker: required
exclusions:
rules:
- linters:
- kubeapilinter
path: .*
text: "(optionalorrequired: embedded field .*.metav1.ObjectMeta must be marked as optional or required)"
# NOTE: kubeapilinter has been introduced after v1alpha1/konnect_gateway_controlplane_types.go
# has been created and to prevent changes in the API and docs we disable the rule.
- linters:
- kubeapilinter
path: api/konnect/v1alpha1/konnect_gateway_controlplane_types.go
text: "nobools: field CreateControlPlaneRequest.CloudGateway pointer should not use a bool. Use a string type with meaningful constant values as an enum."
# NOTE: Let the old APIs be as they are.
- linters:
- kubeapilinter
path: api/konnect/v1alpha1/.*
text: "conditions: Conditions field is missing the following markers: patchStrategy=merge, patchMergeKey=type"
# NOTE: Let the old APIs be as they are.
- linters:
- kubeapilinter
path: api/konnect/v1alpha1/.*
text: "conditions: Conditions field has incorrect tags, should be:"
# NOTE: Let the old APIs be as they are.
- linters:
- kubeapilinter
path: api/konnect/v1alpha1/.*
text: "conditions: Conditions field must be the first field in the struct"
# NOTE: We've already released v2beta1 with Duration fields in ControlPlane spec.
- linters:
- kubeapilinter
path: api/gateway-operator/v2beta1/controlplane_types.go
text: 'nodurations: field ControlPlane.* pointer should not use a Duration'
# TODO: remove this.
- linters:
- kubeapilinter
path: api/(konnect|gateway-operator).*
text: "requiredfields: field .* should have the omitempty tag."
# TODO: remove this.
- linters:
- kubeapilinter
path: api/konnect/.*
text: "requiredfields: field .* does not allow the zero value. It must have the omitzero tag."
# TODO: remove this.
- linters:
- kubeapilinter
path: api/konnect/(v1alpha1|v1alpha2)/.*
text: 'requiredfields: field .* has a valid zero value .* but the validation is not complete'
# TODO: remove this.
- linters:
- kubeapilinter
path: api/gateway-operator/v2beta1/shared_types.go
text: 'requiredfields: field .* has a valid zero value .* but the validation is not complete'
# TODO: remove this.
- linters:
- kubeapilinter
path: api/gateway-operator/v2beta1/shared_types.go
text: 'requiredfields: field Strategy has a valid zero value .* and should be a pointer.'
# TODO: remove this.
- linters:
- kubeapilinter
path: api/(konnect/v1alpha(1|2)|gateway-operator/v2beta1)/.*
text: 'maxlength: field .* must have a maximum items, add kubebuilder:validation:MaxItems marker'
# TODO: remove this.
- linters:
- kubeapilinter
path: api/(common/v1alpha1|konnect/v1alpha1|konnect/v1alpha2)/.*
text: 'maxlength: field .* must have a maximum length, add kubebuilder:validation:(items:)?MaxLength marker'