Skip to content

Commit 236988f

Browse files
committed
Enable ssatags KAL linter
Signed-off-by: Stefan Büringer buringerst@vmware.com
1 parent e1b4e4f commit 236988f

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

.golangci-kal.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ linters:
2727
# having the `omitempty` value in their `json` tag where appropriate.
2828
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
2929
- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
30+
- "ssatags" # Ensure array fields have the appropriate listType markers
3031
- "statusoptional" # Ensure all first children within status should be optional.
3132
- "statussubresource" # All root objects that have a `status` field should have a status subresource.
3233
- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
@@ -44,19 +45,21 @@ linters:
4445
isFirstField: Warn # Require conditions to be the first field in the status struct.
4546
usePatchStrategy: Forbid # Require conditions to be the first field in the status struct.
4647
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
47-
optionalFields:
48+
optionalfields:
4849
pointers:
4950
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
5051
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
5152
omitempty:
5253
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
53-
# jsonTags:
54+
# jsontags:
5455
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
55-
# optionalOrRequired:
56+
# optionalorrequired:
5657
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
5758
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
58-
# requiredFields:
59+
# requiredfields:
5960
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
61+
# ssatags:
62+
# listTypeSetUsage: Warn | Ignore # The policy for listType=set usage on object arrays. Defaults to `Warn`.
6063

6164
exclusions:
6265
generated: strict
@@ -83,14 +86,19 @@ linters:
8386
text: "Conditions field must be a slice of metav1.Condition"
8487
linters:
8588
- kubeapilinter
89+
- path: "api/addons/v1beta2|api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/ipam/v1beta2|api/runtime/v1beta2"
90+
text: "ssatags: Conditions should have a listType marker for proper Server-Side Apply behavior"
91+
linters:
92+
- kubeapilinter
8693
- path: "api/core/v1beta2"
8794
text: "field Conditions type Conditions must have a maximum items, add kubebuilder:validation:MaxItems marker"
8895
linters:
8996
- kubeapilinter
9097

9198
## Excludes for current clusterctl v1alpha3 and Runtime Hooks v1alpha1 apiVersions (can be fixed once we bump their apiVersion).
99+
# Note: The types in api/runtime/hooks/v1alpha1 are not CRDs, so e.g. SSA markers don't make sense there.
92100
- path: "cmd/clusterctl/api/v1alpha3|api/runtime/hooks/v1alpha1"
93-
text: "optionalfields|maxlength"
101+
text: "optionalfields|maxlength|ssatags"
94102
linters:
95103
- kubeapilinter
96104

@@ -174,6 +182,11 @@ linters:
174182
text: "optionalfields: field (Format|Encoding|Type|DeletePolicy|FailurePolicy) is optional and (should be a pointer|has a valid zero value)"
175183
linters:
176184
- kubeapilinter
185+
# KAL incorrectly recommends a listType marker on []byte fields: https://github.com/kubernetes-sigs/kube-api-linter/issues/118
186+
- path: "api/runtime/v1beta2/extensionconfig_types.go|api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
187+
text: "ssatags: (CertificateAuthorityData|CABundle) should have a listType marker for proper Server-Side Apply behavior"
188+
linters:
189+
- kubeapilinter
177190

178191
issues:
179192
max-same-issues: 0

hack/tools/.custom-gcl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name: golangci-lint-kube-api-linter
33
destination: ./bin
44
plugins:
55
- module: 'sigs.k8s.io/kube-api-linter'
6-
version: v0.0.0-20250626111229-e719da12d840
6+
version: v0.0.0-20250709144528-029010b5da35

0 commit comments

Comments
 (0)