Skip to content

Commit c7c3e86

Browse files
authored
Merge pull request #12326 from sbueringer/pr-bump-kal-drop-items
🌱 Bump KAL to 20250605073038, cleanup excludes, fix IPAM prefix field, add MaxItems to Machine.status.addresses
2 parents 70d9d4e + 331f931 commit c7c3e86

File tree

9 files changed

+81
-30
lines changed

9 files changed

+81
-30
lines changed

.golangci-kal.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,63 @@ linters:
5757
- internal/api/.*
5858
- ".*_test.go" # Exclude test files.
5959
rules:
60-
# KAL should only run on API folders.
60+
## KAL should only run on API folders.
6161
- path-except: "api//*"
6262
linters:
6363
- kubeapilinter
64+
65+
## Excludes that can be removed once v1alpha1/v1beta1 apiVersions are dropped
66+
67+
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types, these fields will be removed once v1alpha1/v1beta1 is removed.
6468
- 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/*"
6569
text: "Conditions field must be a slice of metav1.Condition"
6670
linters:
6771
- kubeapilinter
72+
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
73+
text: "field Conditions type Conditions must have a maximum items, add kubebuilder:validation:MaxItems marker"
74+
linters:
75+
- kubeapilinter
76+
# excludes for v1alpha1/v1beta1 API packages
6877
- path: "api/core/v1beta1/*"
6978
text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
7079
linters:
7180
- kubeapilinter
72-
- path: "api/ipam/v1beta2/*|api/ipam/v1alpha1/*|api/ipam/v1beta1/*"
81+
- path: "api/ipam/v1alpha1/*|api/ipam/v1beta1/*"
7382
text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
7483
linters:
7584
- kubeapilinter
76-
# clusterctl and Runtime Hooks can be fixed once we bump their apiVersion.
85+
- path: "api/core/v1beta1/*"
86+
text: "field Addresses type MachineAddresses must have a maximum items, add kubebuilder:validation:MaxItems marker"
87+
linters:
88+
- kubeapilinter
89+
90+
## Excludes for clusterctl and Runtime Hooks (can be fixed once we bump their apiVersion)
7791
- path: "cmd/clusterctl/api/v1alpha3|api/runtime/hooks/v1alpha1"
7892
text: "maxlength"
7993
linters:
8094
- kubeapilinter
81-
# controller-gen does not allow to add MaxItems to Schemaless fields
95+
96+
## controller-gen does not allow to add MaxItems to Schemaless fields
8297
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
8398
text: "maxlength: field (AllOf|OneOf|AnyOf) must have a maximum items, add kubebuilder:validation:MaxItems marker"
8499
linters:
85100
- kubeapilinter
86-
# It does not make sense to add a maxItems marker on the *List structs as they are not used to generate CRD YAMLs.
87-
# This exclude will be removed once https://github.com/JoelSpeed/kubeapilinter/issues/38 is resolved.
88-
- path: "api/core/v1beta2/*|api/addons/v1beta2/*|api/core/v1beta1/*|api/v1alpha1/*|api/addons/v1beta1/*"
89-
text: "maxlength: field Items must have a maximum items, add kubebuilder:validation:MaxItems marker"
90-
linters:
91-
- kubeapilinter
101+
102+
## Removal of bool fields of existing types requires further discussion
92103
- 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/*"
93104
text: "nobools"
94105
linters:
95106
- kubeapilinter
96-
# We follow the current CustomResourceDefinition field's json tag pattern.
107+
108+
## Excludes for JSONSchemaProps
109+
# We want to align to the JSON tags of the CustomResourceDefinition fields.
97110
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
98111
text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
99112
linters:
100113
- kubeapilinter
101-
# The following rules are disabled until we migrate to the new API.
114+
115+
## TODO: The following rules are disabled until we migrate to the new API.
116+
# Note: Maybe this has to stay a pointer for marshalling reasons.
102117
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go|api/bootstrap/kubeadm/v1beta1/kubeadm_types.go"
103118
text: "field Token is marked as required, should not be a pointer"
104119
linters:
@@ -107,10 +122,6 @@ linters:
107122
text: "field Ref is marked as required, should not be a pointer"
108123
linters:
109124
- kubeapilinter
110-
- path: "api/core/v1beta2/*|api/addons/v1beta2/*|api/v1alpha1/*|api/core/v1beta1/*|api/v1alpha3/*|api/addons/v1beta1/*|api/runtime/v1beta2/*|api/runtime/v1alpha1/*|api/runtime/hooks/v1alpha1/*"
111-
text: "field Items must be marked as optional or required"
112-
linters:
113-
- kubeapilinter
114125
issues:
115126
max-same-issues: 0
116127
max-issues-per-linter: 0

api/core/v1beta2/common_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ type MachineAddress struct {
307307
}
308308

309309
// MachineAddresses is a slice of MachineAddress items to be used by infrastructure providers.
310+
// +kubebuilder:validation:MaxItems=32
310311
type MachineAddresses []MachineAddress
311312

312313
// ObjectMeta is metadata that all persisted resources must have, which includes all objects

api/ipam/v1alpha1/zz_generated.conversion.go

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/ipam/v1beta1/zz_generated.conversion.go

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/ipam/v1beta2/ipaddress_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type IPAddressSpec struct {
3939

4040
// prefix is the prefix of the address.
4141
// +required
42-
Prefix int `json:"prefix"`
42+
Prefix int32 `json:"prefix"`
4343

4444
// gateway is the network gateway of the network the address is from.
4545
// +optional

api/runtime/hooks/v1alpha1/topologymutation_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type GeneratePatchesRequest struct {
3939
Variables []Variable `json:"variables,omitempty"`
4040

4141
// items is the list of templates to generate patches for.
42+
// +required
4243
Items []GeneratePatchesRequestItem `json:"items"`
4344
}
4445

config/crd/bases/cluster.x-k8s.io_machines.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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-20250515061849-37102c8f17a9
6+
version: v0.0.0-20250605073038-74075c8eae51

0 commit comments

Comments
 (0)