Skip to content

Commit 92443fc

Browse files
authored
Merge pull request #12445 from sbueringer/pr-restructure-lint-config
🌱 Restructure excludes in KAL linter config
2 parents ea1a774 + 5511c49 commit 92443fc

File tree

1 file changed

+35
-66
lines changed

1 file changed

+35
-66
lines changed

.golangci-kal.yml

Lines changed: 35 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -72,119 +72,88 @@ linters:
7272
linters:
7373
- kubeapilinter
7474

75-
## Excludes that can be removed once v1alpha1/v1beta1 apiVersions are dropped
75+
## Excludes for old apiVersions that can be removed once the apiVersions are dropped (we don't want to make any changes to these APIs).
76+
- path: "api/addons/v1beta1|api/bootstrap/kubeadm/v1beta1|api/controlplane/kubeadm/v1beta1|api/core/v1beta1|api/ipam/v1beta1|api/ipam/v1alpha1|api/runtime/v1alpha1"
77+
linters:
78+
- kubeapilinter
7679

77-
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types, these fields will be removed once v1alpha1/v1beta1 is removed.
78-
- path: "api/addons/v1beta2/*|api/bootstrap/kubeadm/v1beta2/*|api/controlplane/kubeadm/v1beta2/*|api/core/v1beta2/*|api/ipam/v1beta2/*|api/runtime/v1beta2/*|api/addons/v1beta1/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/core/v1beta1/*|api/ipam/v1beta1/*|api/ipam/v1alpha1/*|api/runtime/v1alpha1/*"
80+
## Excludes for current apiVersions that can be removed once v1beta1 is removed.
81+
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types.
82+
- path: "api/addons/v1beta2|api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/ipam/v1beta2|api/runtime/v1beta2"
7983
text: "Conditions field must be a slice of metav1.Condition"
8084
linters:
8185
- kubeapilinter
82-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
86+
- path: "api/core/v1beta2"
8387
text: "field Conditions type Conditions must have a maximum items, add kubebuilder:validation:MaxItems marker"
8488
linters:
8589
- kubeapilinter
86-
# excludes for v1alpha1/v1beta1 API packages
87-
- path: "api/core/v1beta1/*"
88-
text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
89-
linters:
90-
- kubeapilinter
91-
- path: "api/ipam/v1alpha1/*|api/ipam/v1beta1/*"
92-
text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
93-
linters:
94-
- kubeapilinter
95-
- path: "api/core/v1beta1/*"
96-
text: "field Addresses type MachineAddresses must have a maximum items, add kubebuilder:validation:MaxItems marker"
97-
linters:
98-
- kubeapilinter
99-
- path: "api/bootstrap/kubeadm/v1beta1/*"
100-
text: "nomaps: APIEndpoints should not use a map type, use a list type with a unique name/identifier instead"
101-
linters:
102-
- kubeapilinter
103-
- path: "api/core/v1beta1/*"
104-
text: "nomaps: FailureDomains should not use a map type, use a list type with a unique name/identifier instead"
105-
linters:
106-
- kubeapilinter
107-
- path: "api/addons/v1beta1/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/core/v1beta1/*|api/ipam/v1beta1/*|api/ipam/v1alpha1/*|api/runtime/v1alpha1/*|cmd/clusterctl/api/v1alpha3/*"
108-
text: "optionalfields"
109-
linters:
110-
- kubeapilinter
111-
- path: "api/core/v1beta1/clusterclass_types.go"
112-
text: "field Ref is marked as required, should not be a pointer"
113-
linters:
114-
- kubeapilinter
11590

116-
## Excludes for clusterctl and Runtime Hooks (can be fixed once we bump their apiVersion)
91+
## Excludes for current clusterctl v1alpha3 and Runtime Hooks v1alpha1 apiVersions (can be fixed once we bump their apiVersion).
11792
- path: "cmd/clusterctl/api/v1alpha3|api/runtime/hooks/v1alpha1"
118-
text: "maxlength"
93+
text: "optionalfields|maxlength"
11994
linters:
12095
- kubeapilinter
12196

122-
## controller-gen does not allow to add MaxItems to Schemaless fields
123-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
97+
## Excludes for JSONSchemaProps
98+
# controller-gen does not allow to add MaxItems to Schemaless fields
99+
- path: "api/core/v1beta2/clusterclass_types.go"
124100
text: "maxlength: field (AllOf|OneOf|AnyOf) must have a maximum items, add kubebuilder:validation:MaxItems marker"
125101
linters:
126102
- kubeapilinter
127-
128-
## Removal of bool fields of existing types requires further discussion
129-
- path: "api/bootstrap/kubeadm/v1beta2/*|api/controlplane/kubeadm/v1beta2/*|api/core/v1beta2/*|api/addons/v1beta2/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/v1alpha1/*|api/core/v1beta1/*|api/addons/v1beta1/*"
130-
text: "nobools"
131-
linters:
132-
- kubeapilinter
133-
134-
## Excludes for JSONSchemaProps
135103
# We want to align to the JSON tags of the CustomResourceDefinition fields.
136-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
104+
- path: "api/core/v1beta2/clusterclass_types"
137105
text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
138106
linters:
139107
- kubeapilinter
140108
# We want to align Properties to the corresponding field in CustomResourceDefinitions.
141-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
109+
- path: "api/core/v1beta2/clusterclass_types"
142110
text: "Properties should not use a map type, use a list type with a unique name/identifier instead"
143111
linters:
144112
- kubeapilinter
145113

114+
## Removal of bool fields of existing types requires further discussion
115+
- path: "api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/addons/v1beta2"
116+
text: "nobools"
117+
linters:
118+
- kubeapilinter
119+
146120
## Excludes for kubeadm types
147121
# We want to align the FeatureGates field to the FeatureGates field in kubeadm.
148-
- path: "api/bootstrap/kubeadm/v1beta2/*|api/bootstrap/kubeadm/v1beta1/*"
122+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
149123
text: "nomaps: FeatureGates should not use a map type, use a list type with a unique name/identifier instead"
150124
linters:
151125
- kubeapilinter
126+
# Note: Maybe this has to stay a pointer for marshalling reasons.
127+
# TODO: we should eventually remove the pointer: https://github.com/kubernetes-sigs/cluster-api/issues/10852
128+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
129+
text: "field Token is marked as required, should not be a pointer"
130+
linters:
131+
- kubeapilinter
152132

153133
## Excludes for optionalfields
154134
# Empty Bootstrap object is blocked via validating webhooks. This cannot be detected by KAL (same if we move the validation to CEL).
155135
- path: "api/core/v1beta2/machine_types.go"
156136
text: "optionalfields: field (Bootstrap) is optional and (should be a pointer|should have the omitempty tag|has a valid zero value)"
157137
linters:
158138
- kubeapilinter
139+
140+
# TODO: Excludes that should be removed once the corresponding issues in KAL are fixed
159141
# KAL incorrectly reports that the Taints field doesn't have to be a pointer (it has to be to preserve []).
142+
# See: https://github.com/kubernetes-sigs/kube-api-linter/issues/116
160143
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
161144
text: "optionalfields: field Taints is optional but the underlying type does not need to be a pointer. The pointer should be removed."
162145
linters:
163146
- kubeapilinter
164-
165-
## TODO: The following rules are disabled until we migrate to the new API.
166-
# Note: Maybe this has to stay a pointer for marshalling reasons.
167-
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go|api/bootstrap/kubeadm/v1beta1/kubeadm_types.go"
168-
text: "field Token is marked as required, should not be a pointer"
169-
linters:
170-
- kubeapilinter
171-
172-
# Audit the entire hook types + builtins from a serialization point of view when bumping the API (this is not a CRD)
173-
- path: "api/runtime/hooks/v1alpha1/*"
174-
text: "optionalfields"
175-
linters:
176-
- kubeapilinter
177-
178147
# KAL does not handle omitzero correctly yet: https://github.com/kubernetes-sigs/kube-api-linter/pull/115
179148
- path: "api/.*"
180149
text: "optionalfields: field Status is optional and should (be a pointer|have the omitempty tag)"
181150
linters:
182151
- kubeapilinter
183-
- path: "api/bootstrap/kubeadm/v1beta2/*"
152+
- path: "api/bootstrap/kubeadm/v1beta2"
184153
text: "optionalfields: field (Spec|NodeRegistration|LocalAPIEndpoint|Etcd|APIServer|ControllerManager|Scheduler|DNS|Discovery|ObjectMeta) is optional and should (be a pointer|have the omitempty tag)"
185154
linters:
186155
- kubeapilinter
187-
- path: "api/controlplane/kubeadm/v1beta2/*"
156+
- path: "api/controlplane/kubeadm/v1beta2"
188157
text: "optionalfields: field (Spec|ObjectMeta|KubeadmConfigSpec) is optional and should (be a pointer|have the omitempty tag)"
189158
linters:
190159
- kubeapilinter
@@ -200,12 +169,12 @@ linters:
200169
text: "optionalfields: field AddressRef is optional and should (be a pointer|have the omitempty tag)"
201170
linters:
202171
- kubeapilinter
203-
204-
# KAL does not handle enum markers on enum types yet: https://github.com/kubernetes-sigs/kube-api-linter/issues/113
172+
# KAL does not handle enum markers on enum types yet: https://github.com/kubernetes-sigs/kube-api-linter/issues/113
205173
- path: ".*"
206174
text: "optionalfields: field (Format|Encoding|Type|DeletePolicy) is optional and (should be a pointer|has a valid zero value)"
207175
linters:
208176
- kubeapilinter
177+
209178
issues:
210179
max-same-issues: 0
211180
max-issues-per-linter: 0

0 commit comments

Comments
 (0)