You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .golangci-kal.yml
+17-77Lines changed: 17 additions & 77 deletions
Original file line number
Diff line number
Diff line change
@@ -24,14 +24,14 @@ linters:
24
24
- "nobools"# Bools do not evolve over time, should use enums instead.
25
25
- "nofloats"# Ensure floats are not used.
26
26
- "nomaps"# Ensure maps are not used.
27
+
- "notimestamp"# Prevents usage of 'Timestamp' fields
27
28
- "optionalfields"# Ensure that all fields marked as optional adhere to being pointers and
28
29
# having the `omitempty` value in their `json` tag where appropriate.
29
30
- "optionalorrequired"# Every field should be marked as `+optional` or `+required`.
30
31
- "requiredfields"# Required fields should not be pointers, and should not have `omitempty`.
31
32
- "ssatags"# Ensure array fields have the appropriate listType markers
32
33
- "statusoptional"# Ensure all first children within status should be optional.
33
34
- "statussubresource"# All root objects that have a `status` field should have a status subresource.
34
-
- "notimestamp"# Prevents usage of 'Timestamp' fields
35
35
- "uniquemarkers"# Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
36
36
37
37
# Per discussion in July 2024, we are keeping phase fields for now.
@@ -60,15 +60,6 @@ linters:
60
60
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
61
61
omitempty:
62
62
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
63
-
# jsontags:
64
-
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
65
-
# optionalorrequired:
66
-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
67
-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
68
-
# requiredfields:
69
-
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
70
-
# ssatags:
71
-
# listTypeSetUsage: Warn | Ignore # The policy for listType=set usage on object arrays. Defaults to `Warn`.
72
63
73
64
exclusions:
74
65
generated: strict
@@ -111,7 +102,7 @@ linters:
111
102
## Excludes for current clusterctl v1alpha3 and Runtime Hooks v1alpha1 apiVersions (can be fixed once we bump their apiVersion).
112
103
# Note: The types in api/runtime/hooks/v1alpha1 are not CRDs, so e.g. SSA markers don't make sense there.
# It's simpler to check these fields against nil vs. using reflect.DeepEqual everywhere.
140
131
- path: "api/core/v1beta2/clusterclass_types.go"
141
-
text: "optionalfields: field (AdditionalProperties|Items|Not) (is optional and does not allow the zero value. It must have the omitzero tag|is optional and does not have a valid zero value. The field does not need to be a pointer)"
132
+
text: "optionalfields: field (AdditionalProperties|Items|Not) does not allow the zero value. (The field does not need to be a pointer|It must have the omitzero tag)"
142
133
linters:
143
134
- kubeapilinter
144
135
@@ -155,83 +146,32 @@ linters:
155
146
linters:
156
147
- kubeapilinter
157
148
158
-
## Excludes for optionalfields
149
+
## Excludes for requiredfields
159
150
# Empty Bootstrap object is blocked via validating webhooks. This cannot be detected by KAL (same if we move the validation to CEL).
160
151
- path: "api/core/v1beta2/machine_types.go"
161
-
text: "optionalfields: field (Bootstrap) is optional and (should be a pointer|should have the omitempty tag|has a valid zero value)"
152
+
text: "requiredfields: field Bootstrap has a valid zero value \\({}\\), but the validation is not complete \\(e.g. min properties/adding required fields\\). The field should be a pointer to allow the zero value to be set. If the zero value is not a valid use case, complete the validation and remove the pointer."
153
+
linters:
154
+
- kubeapilinter
155
+
156
+
## Excludes for optionalfields
157
+
## The ExtraEnvs field intentionally has type *[]EnvVar.
158
+
## Today we have MinItems=1, but we might have to support MinItems=0 in the future if kubeadm starts supporting it.
text: "optionalfields: field ExtraEnvs is optional and does not allow the zero value. The field does not need to be a pointer."
174
-
linters:
175
-
- kubeapilinter
176
-
# KAL does not handle omitzero correctly yet: https://github.com/kubernetes-sigs/kube-api-linter/pull/115
177
-
- path: "api/.*"
178
-
text: "optionalfields: field (Status|Initialization) is optional and should (be a pointer|have the omitempty tag)"
179
-
linters:
180
-
- kubeapilinter
181
-
- path: "api/.*"
182
-
text: "optionalfields: field (LastAppliedTime|Expires|After|LastUpdated|CertificatesExpiryDate|NodeDrainStartTime|WaitForNodeVolumeDetachStartTime) is optional and should (be a pointer|have the omitempty tag)"
183
-
linters:
184
-
- kubeapilinter
185
-
- path: "api/bootstrap/kubeadm/v1beta2"
186
-
text: "optionalfields: field (Spec|NodeRegistration|LocalAPIEndpoint|Etcd|APIServer|ControllerManager|Scheduler|DNS|Discovery|ObjectMeta) is optional and should (be a pointer|have the omitempty tag)"
187
-
linters:
188
-
- kubeapilinter
189
-
- path: "api/controlplane/kubeadm/v1beta2"
190
-
text: "optionalfields: field (Spec|ObjectMeta|KubeadmConfigSpec|Remediation|Rollout|Before|Strategy|RollingUpdate|MachineTemplate) is optional and should (be a pointer|have the omitempty tag)"
191
-
linters:
192
-
- kubeapilinter
193
-
- path: "api/core/v1beta2/cluster_types.go"
194
-
text: "optionalfields: field (ClusterNetwork|Services|Pods|ControlPlaneEndpoint|ControlPlane|Workers|Metadata|Variables|Strategy|Rollout|RollingUpdate) is optional and should (be a pointer|have the omitempty tag)"
195
-
linters:
196
-
- kubeapilinter
197
-
- path: "api/core/v1beta2/clusterclass_types.go"
198
-
text: "optionalfields: field (Workers|Metadata|ControlPlane|Strategy|Infrastructure|DeprecatedV1Beta1Metadata|Rollout|RollingUpdate) is optional and should (be a pointer|have the omitempty tag)"
text: "optionalfields: field (Naming|HealthCheck|MachineNaming|Deletion) is optional and should (be a pointer|have the omitempty tag)"
215
-
linters:
216
-
- kubeapilinter
217
-
218
-
# TODO: Excludes that should be removed once we will get the new version of the requiredfields linter
219
-
- path: "api/.*"
220
-
text: "requiredfields: field .* is marked as required, but has the omitempty tag"
221
-
linters:
222
-
- kubeapilinter
223
-
- path: "api/.*"
224
-
text: "requiredfields: field (Applied|Value|Layout|RetryCount|Required|Prefix|TimeoutSeconds) is marked as required, should not be a pointer"
225
-
linters:
226
-
- kubeapilinter
227
-
228
-
# TODO: Excludes that should be removed once https://github.com/kubernetes-sigs/kube-api-linter/issues/132 will be fixed
229
-
- path: "api/.*"
230
-
text: "optionalfields: field (.*) is optional and (should have the omitempty tag|should be a pointer)"
231
-
linters:
232
-
- kubeapilinter
233
-
- path: "api/.*"
234
-
text: "optionalfields: field (.*) is optional and has a valid zero value \\({}\\), but the validation is not complete \\(e.g. min properties/adding required fields\\). The field should be a pointer to allow the zero value to be set. If the zero value is not a valid use case, complete the validation and remove the pointer."
174
+
text: "requiredfields: field Token has a valid zero value \\({\"\": \"\", \"\": \"\"}\\) and should be a pointer."
0 commit comments