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
+14-80Lines changed: 14 additions & 80 deletions
Original file line number
Diff line number
Diff line change
@@ -23,14 +23,14 @@ linters:
23
23
- "nobools"# Bools do not evolve over time, should use enums instead.
24
24
- "nofloats"# Ensure floats are not used.
25
25
- "nomaps"# Ensure maps are not used.
26
+
- "notimestamp"# Prevents usage of 'Timestamp' fields
26
27
- "optionalfields"# Ensure that all fields marked as optional adhere to being pointers and
27
28
# having the `omitempty` value in their `json` tag where appropriate.
28
29
- "optionalorrequired"# Every field should be marked as `+optional` or `+required`.
29
30
- "requiredfields"# Required fields should not be pointers, and should not have `omitempty`.
30
31
- "ssatags"# Ensure array fields have the appropriate listType markers
31
32
- "statusoptional"# Ensure all first children within status should be optional.
32
33
- "statussubresource"# All root objects that have a `status` field should have a status subresource.
33
-
- "notimestamp"# Prevents usage of 'Timestamp' fields
34
34
- "uniquemarkers"# Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
35
35
36
36
# Per discussion in July 2024, we are keeping phase fields for now.
@@ -52,15 +52,6 @@ linters:
52
52
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
53
53
omitempty:
54
54
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
55
-
# jsontags:
56
-
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
57
-
# optionalorrequired:
58
-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
59
-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
60
-
# requiredfields:
61
-
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
62
-
# ssatags:
63
-
# listTypeSetUsage: Warn | Ignore # The policy for listType=set usage on object arrays. Defaults to `Warn`.
64
55
65
56
exclusions:
66
57
generated: strict
@@ -103,7 +94,7 @@ linters:
103
94
## Excludes for current clusterctl v1alpha3 and Runtime Hooks v1alpha1 apiVersions (can be fixed once we bump their apiVersion).
104
95
# 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.
132
123
- path: "api/core/v1beta2/clusterclass_types.go"
133
-
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)"
124
+
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)"
134
125
linters:
135
126
- kubeapilinter
136
127
@@ -147,83 +138,26 @@ linters:
147
138
linters:
148
139
- kubeapilinter
149
140
150
-
## Excludes for optionalfields
141
+
## Excludes for requiredfields
151
142
# Empty Bootstrap object is blocked via validating webhooks. This cannot be detected by KAL (same if we move the validation to CEL).
152
143
- path: "api/core/v1beta2/machine_types.go"
153
-
text: "optionalfields: field (Bootstrap) is optional and (should be a pointer|should have the omitempty tag|has a valid zero value)"
144
+
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."
154
145
linters:
155
146
- kubeapilinter
156
147
157
-
# TODO: Excludes that should be removed once the corresponding issues in KAL are fixed
158
-
# KAL incorrectly reports that the Taints field doesn't have to be a pointer (it has to be to preserve []).
text: "optionalfields: field ExtraEnvs is optional and does not allow the zero value. The field does not need to be a pointer."
166
-
linters:
167
-
- kubeapilinter
168
-
# KAL does not handle omitzero correctly yet: https://github.com/kubernetes-sigs/kube-api-linter/pull/115
169
-
- path: "api/.*"
170
-
text: "optionalfields: field (Status|Initialization) is optional and should (be a pointer|have the omitempty tag)"
171
-
linters:
172
-
- kubeapilinter
173
-
- path: "api/.*"
174
-
text: "optionalfields: field (LastAppliedTime|Expires|After|LastUpdated|CertificatesExpiryDate|NodeDrainStartTime|WaitForNodeVolumeDetachStartTime) is optional and should (be a pointer|have the omitempty tag)"
175
-
linters:
176
-
- kubeapilinter
177
-
- path: "api/bootstrap/kubeadm/v1beta2"
178
-
text: "optionalfields: field (Spec|NodeRegistration|LocalAPIEndpoint|Etcd|APIServer|ControllerManager|Scheduler|DNS|Discovery|ObjectMeta) is optional and should (be a pointer|have the omitempty tag)"
179
-
linters:
180
-
- kubeapilinter
181
-
- path: "api/controlplane/kubeadm/v1beta2"
182
-
text: "optionalfields: field (Spec|ObjectMeta|KubeadmConfigSpec|Remediation|Rollout|Before|Strategy|RollingUpdate|MachineTemplate) is optional and should (be a pointer|have the omitempty tag)"
183
-
linters:
184
-
- kubeapilinter
185
-
- path: "api/core/v1beta2/cluster_types.go"
186
-
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)"
187
-
linters:
188
-
- kubeapilinter
189
-
- path: "api/core/v1beta2/clusterclass_types.go"
190
-
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)"
152
+
text: "optionalfields: field ExtraEnvs does not allow the zero value. The field does not need to be a pointer."
207
153
linters:
208
154
- kubeapilinter
209
155
210
-
# TODO: Excludes that should be removed once we will get the new version of the requiredfields linter
211
-
- path: "api/.*"
212
-
text: "requiredfields: field .* is marked as required, but has the omitempty tag"
213
-
linters:
214
-
- kubeapilinter
215
-
- path: "api/.*"
216
-
text: "requiredfields: field (Applied|Value|Layout|RetryCount|Required|Prefix|TimeoutSeconds) is marked as required, should not be a pointer"
217
-
linters:
218
-
- kubeapilinter
219
-
220
-
# TODO: Excludes that should be removed once https://github.com/kubernetes-sigs/kube-api-linter/issues/132 will be fixed
221
-
- path: "api/.*"
222
-
text: "optionalfields: field (.*) is optional and (should have the omitempty tag|should be a pointer)"
223
-
linters:
224
-
- kubeapilinter
225
-
- path: "api/.*"
226
-
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."
156
+
# TODO: Excludes that should be removed once the corresponding issues in KAL are fixed
157
+
# KAL incorrectly reports that the Taints field doesn't have to be a pointer (it has to be to preserve []).
0 commit comments