Skip to content

Commit 155e660

Browse files
fabriziopandinisbueringerchrischdi
authored
⚠️ Add v1beta2 types (#12037)
* Add v1beta2 types * Deprecate v1beta1 types, add conversions * Fix conversions from older API versions * Fix conversions from kubeadm API * Change imports to v1beta2 # Conflicts: # util/conversion/conversion.go # util/conversion/conversion_test.go * Fix web hooks * Make generate manifests * Small fix in API types * Change imports to v1beta2 # Conflicts: # cmd/clusterctl/client/cluster/client.go * Add conversion to v1beta1 for runtime hooks * Fix unit tests and linters errors * Fix CI * Cleanup unnecessary v1beta1 usage * Fix review findings * fixup unit tests * Fix CAPD ClusterClass to avoid Invalid value null errors due to additional conversion webhook * Fix e2e tests * fixup * e2e: support reading v1beta1 and v1beta2 clusters for modifyMachineDeployments * e2e: use scheme converter in scale test * Allow upgrade from v1beta1 * Fix MP error in clusterctl upgrade test * Fix clusterctl upgrade tests * Fix linter findings & e2e tests --------- Co-authored-by: Stefan Bueringer <[email protected]> Co-authored-by: Christian Schlotter <[email protected]>
1 parent 03cb3b4 commit 155e660

File tree

716 files changed

+52615
-5493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

716 files changed

+52615
-5493
lines changed

Diff for: .golangci-kal.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ issues:
6262
- path-except: "api//*"
6363
linters:
6464
- kal
65-
- path: "api/v1beta1/*|api/v1alpha1/*|api/addons/v1beta1/*"
65+
- path: "api/v1beta2/*|api/addons/v1beta2/*|api/v1beta1/*|api/v1alpha1/*|api/addons/v1beta1/*"
6666
text: "Conditions field must be a slice of metav1.Condition"
6767
linters:
6868
- kal
69-
- path: "api/v1beta1/*"
69+
- path: "api/v1beta2/*|api/v1beta1/*"
7070
text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
7171
linters:
7272
- kal
73-
- path: "exp/ipam/api/v1alpha1/*|exp/ipam/api/v1beta1/*"
73+
- path: "exp/ipam/api/v1beta2/*|exp/ipam/api/v1alpha1/*|exp/ipam/api/v1beta1/*"
7474
text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
7575
linters:
7676
- kal
@@ -80,35 +80,35 @@ issues:
8080
linters:
8181
- kal
8282
# controller-gen does not allow to add MaxItems to Schemaless fields
83-
- path: "api/v1beta1/*"
83+
- path: "api/v1beta2/*|api/v1beta1/*"
8484
text: "maxlength: field (AllOf|OneOf|AnyOf) must have a maximum items, add kubebuilder:validation:MaxItems marker"
8585
linters:
8686
- kal
8787
# It does not make sense to add a maxItems marker on the *List structs as they are not used to generate CRD YAMLs.
8888
# This exclude will be removed once https://github.com/JoelSpeed/kal/issues/38 is resolved.
89-
- path: "api/v1beta1/*|api/v1alpha1/*|api/addons/v1beta1/*"
89+
- path: "api/v1beta2/*|api/addons/v1beta2/*|api/v1beta1/*|api/v1alpha1/*|api/addons/v1beta1/*"
9090
text: "maxlength: field Items must have a maximum items, add kubebuilder:validation:MaxItems marker"
9191
linters:
9292
- kal
93-
- path: "api/v1alpha1/*|api/v1beta1/*|api/addons/v1beta1/*"
93+
- path: "api/v1beta2/*|api/addons/v1beta2/*|api/v1alpha1/*|api/v1beta1/*|api/addons/v1beta1/*"
9494
text: "nobools"
9595
linters:
9696
- kal
9797
# We follow the current CustomResourceDefinition field's json tag pattern.
98-
- path: "api/v1beta1/*"
98+
- path: "api/v1beta2/*|api/v1beta1/*"
9999
text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
100100
linters:
101101
- kal
102102
# The following rules are disabled until we migrate to the new API.
103-
- path: "bootstrap/kubeadm/api/v1beta1/kubeadm_types.go"
103+
- path: "bootstrap/kubeadm/api/v1beta2/kubeadm_types.go|bootstrap/kubeadm/api/v1beta1/kubeadm_types.go"
104104
text: "field Token is marked as required, should not be a pointer"
105105
linters:
106106
- kal
107-
- path: "api/v1beta1/clusterclass_types.go"
107+
- path: "api/v1beta2/clusterclass_types.go|api/v1beta1/clusterclass_types.go"
108108
text: "field Ref is marked as required, should not be a pointer"
109109
linters:
110110
- kal
111-
- path: "api/v1alpha1/*|api/v1beta1/*|api/v1alpha3/*|api/addons/v1beta1/*"
111+
- path: "api/v1beta2/*|api/addons/v1beta2/*|api/v1alpha1/*|api/v1beta1/*|api/v1alpha3/*|api/addons/v1beta1/*"
112112
text: "field Items must be marked as optional or required"
113113
linters:
114114
- kal

Diff for: .golangci.yml

+13-1
Original file line numberDiff line numberDiff line change
@@ -121,37 +121,49 @@ linters-settings:
121121
- pkg: sigs.k8s.io/cluster-api/internal/apis/bootstrap/kubeadm/v1alpha4
122122
alias: bootstrapv1alpha4
123123
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1
124+
alias: bootstrapv1beta1
125+
- pkg: sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta2
124126
alias: bootstrapv1
125127
# KCP
126128
- pkg: sigs.k8s.io/cluster-api/internal/apis/controlplane/kubeadm/v1alpha3
127129
alias: controlplanev1alpha3
128130
- pkg: sigs.k8s.io/cluster-api/internal/apis/controlplane/kubeadm/v1alpha4
129131
alias: controlplanev1alpha4
130132
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1
133+
alias: controlplanev1beta1
134+
- pkg: sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta2
131135
alias: controlplanev1
132136
# CAPI
133137
- pkg: sigs.k8s.io/cluster-api/internal/apis/core/v1alpha3
134138
alias: clusterv1alpha3
135139
- pkg: sigs.k8s.io/cluster-api/internal/apis/core/v1alpha4
136140
alias: clusterv1alpha4
137141
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
142+
alias: clusterv1beta1
143+
- pkg: sigs.k8s.io/cluster-api/api/v1beta2
138144
alias: clusterv1
139145
# CAPI exp
140146
- pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha3
141147
alias: expv1alpha3
142148
- pkg: sigs.k8s.io/cluster-api/internal/apis/core/exp/v1alpha4
143149
alias: expv1alpha4
144150
- pkg: sigs.k8s.io/cluster-api/exp/api/v1beta1
151+
alias: expv1beta1
152+
- pkg: sigs.k8s.io/cluster-api/exp/api/v1beta2
145153
alias: expv1
146154
# CAPI exp addons
147155
- pkg: sigs.k8s.io/cluster-api/internal/apis/addons/v1alpha3
148156
alias: addonsv1alpha3
149157
- pkg: sigs.k8s.io/cluster-api/internal/apis/addons/v1alpha4
150158
alias: addonsv1alpha4
151159
- pkg: sigs.k8s.io/cluster-api/api/addons/v1beta1
160+
alias: addonsv1beta1
161+
- pkg: sigs.k8s.io/cluster-api/api/addons/v1beta2
152162
alias: addonsv1
153163
# CAPI exp IPAM
154164
- pkg: sigs.k8s.io/cluster-api/exp/ipam/api/v1beta1
165+
alias: ipamv1beta1
166+
- pkg: sigs.k8s.io/cluster-api/exp/ipam/api/v1beta2
155167
alias: ipamv1
156168
# CAPI exp runtime
157169
- pkg: sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1
@@ -244,7 +256,7 @@ issues:
244256
# should be removed as the referenced deprecated item is removed from the project.
245257
- linters:
246258
- staticcheck
247-
text: "SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|dockerMachine.Spec.Backend.Docker.Bootstrapped|devMachine.Spec.Backend.Docker.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated"
259+
text: "SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|dockerMachine.Spec.Backend.Docker.Bootstrapped|devMachine.Spec.Backend.Docker.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|clusterv1beta1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated"
248260
# Deprecations forGetIPFamily
249261
- linters:
250262
- staticcheck

Diff for: Makefile

+19-13
Original file line numberDiff line numberDiff line change
@@ -449,38 +449,42 @@ generate-go-conversions-core: ## Run all generate-go-conversions-core-* targets
449449

450450
.PHONY: generate-go-conversions-core-api
451451
generate-go-conversions-core-api: $(CONVERSION_GEN) ## Generate conversions go code for core api
452-
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/apis/core/v1alpha3,./internal/apis/core/v1alpha4"
452+
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1beta1,./internal/apis/core/v1alpha3,./internal/apis/core/v1alpha4"
453453
$(CONVERSION_GEN) \
454454
--output-file=zz_generated.conversion.go \
455455
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
456456
./internal/apis/core/v1alpha3 \
457-
./internal/apis/core/v1alpha4
457+
./internal/apis/core/v1alpha4 \
458+
./api/v1beta1
458459

459460
.PHONY: generate-go-conversions-addons-api
460461
generate-go-conversions-addons-api: $(CONVERSION_GEN) ## Generate conversions go code for addons api
461-
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/apis/addons/v1alpha3,./internal/apis/addons/v1alpha4"
462+
$(MAKE) clean-generated-conversions SRC_DIRS="./api/addons/v1beta1,./internal/apis/addons/v1alpha3,./internal/apis/addons/v1alpha4"
462463
$(CONVERSION_GEN) \
463464
--output-file=zz_generated.conversion.go \
464465
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
465466
./internal/apis/addons/v1alpha3 \
466-
./internal/apis/addons/v1alpha4
467+
./internal/apis/addons/v1alpha4 \
468+
./api/addons/v1beta1
467469

468470
.PHONY: generate-go-conversions-core-exp
469471
generate-go-conversions-core-exp: $(CONVERSION_GEN) ## Generate conversions go code for core exp
470-
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/apis/core/exp/v1alpha3,./internal/apis/core/exp/v1alpha4"
472+
$(MAKE) clean-generated-conversions SRC_DIRS="./exp/api/v1beta1,./internal/apis/core/exp/v1alpha3,./internal/apis/core/exp/v1alpha4"
471473
$(CONVERSION_GEN) \
472474
--output-file=zz_generated.conversion.go \
473475
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
474476
./internal/apis/core/exp/v1alpha3 \
475-
./internal/apis/core/exp/v1alpha4
477+
./internal/apis/core/exp/v1alpha4 \
478+
./$(EXP_DIR)/api/v1beta1
476479

477480
.PHONY: generate-go-conversions-core-exp-ipam
478481
generate-go-conversions-core-exp-ipam: $(CONVERSION_GEN) ## Generate conversions go code for core exp IPAM
479-
$(MAKE) clean-generated-conversions SRC_DIRS="./$(EXP_DIR)/ipam/api/v1alpha1"
482+
$(MAKE) clean-generated-conversions SRC_DIRS="./$(EXP_DIR)/ipam/api/v1beta1,./$(EXP_DIR)/ipam/api/v1alpha1"
480483
$(CONVERSION_GEN) \
481484
--output-file=zz_generated.conversion.go \
482485
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
483-
./$(EXP_DIR)/ipam/api/v1alpha1
486+
./$(EXP_DIR)/ipam/api/v1alpha1 \
487+
./$(EXP_DIR)/ipam/api/v1beta1
484488

485489
.PHONY: generate-go-conversions-core-runtime
486490
generate-go-conversions-core-runtime: $(CONVERSION_GEN) ## Generate conversions go code for core runtime
@@ -493,12 +497,13 @@ generate-go-conversions-core-runtime: $(CONVERSION_GEN) ## Generate conversions
493497

494498
.PHONY: generate-go-conversions-kubeadm-bootstrap
495499
generate-go-conversions-kubeadm-bootstrap: $(CONVERSION_GEN) ## Generate conversions go code for kubeadm bootstrap
496-
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/apis/bootstrap/kubeadm"
500+
$(MAKE) clean-generated-conversions SRC_DIRS="./bootstrap/kubeadm/api/v1beta1,./internal/apis/bootstrap/kubeadm"
497501
$(CONVERSION_GEN) \
498502
--output-file=zz_generated.conversion.go \
499503
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
500504
./internal/apis/bootstrap/kubeadm/v1alpha3 \
501-
./internal/apis/bootstrap/kubeadm/v1alpha4
505+
./internal/apis/bootstrap/kubeadm/v1alpha4 \
506+
./bootstrap/kubeadm/api/v1beta1
502507
$(MAKE) clean-generated-conversions SRC_DIRS="./bootstrap/kubeadm/types/upstreamv1beta1,./bootstrap/kubeadm/types/upstreamv1beta2,./bootstrap/kubeadm/types/upstreamv1beta3,./bootstrap/kubeadm/types/upstreamv1beta4"
503508
$(CONVERSION_GEN) \
504509
--output-file=zz_generated.conversion.go \
@@ -510,12 +515,13 @@ generate-go-conversions-kubeadm-bootstrap: $(CONVERSION_GEN) ## Generate convers
510515

511516
.PHONY: generate-go-conversions-kubeadm-control-plane
512517
generate-go-conversions-kubeadm-control-plane: $(CONVERSION_GEN) ## Generate conversions go code for kubeadm control plane
513-
$(MAKE) clean-generated-conversions SRC_DIRS="./internal/apis/controlplane/kubeadm"
518+
$(MAKE) clean-generated-conversions SRC_DIRS="./controlplane/kubeadm/api/v1beta1,./internal/apis/controlplane/kubeadm"
514519
$(CONVERSION_GEN) \
515520
--output-file=zz_generated.conversion.go \
516521
--go-header-file=./hack/boilerplate/boilerplate.generatego.txt \
517522
./internal/apis/controlplane/kubeadm/v1alpha3 \
518-
./internal/apis/controlplane/kubeadm/v1alpha4
523+
./internal/apis/controlplane/kubeadm/v1alpha4 \
524+
./controlplane/kubeadm/api/v1beta1
519525

520526
.PHONY: generate-go-conversions-docker-infrastructure
521527
generate-go-conversions-docker-infrastructure: $(CONVERSION_GEN) ## Generate conversions go code for docker infrastructure provider
@@ -534,7 +540,7 @@ generate-go-conversions-test-extension: $(CONVERSION_GEN) ## Generate conversion
534540
.PHONY: generate-go-openapi
535541
generate-go-openapi: $(OPENAPI_GEN) ## Generate openapi go code for runtime SDK
536542
@mkdir -p ./tmp/sigs.k8s.io; ln -s $(ROOT_DIR) ./tmp/sigs.k8s.io/; cd ./tmp; \
537-
for pkg in "api/v1beta1" "$(EXP_DIR)/runtime/hooks/api/v1alpha1"; do \
543+
for pkg in "api/v1beta2" "api/v1beta1" "$(EXP_DIR)/runtime/hooks/api/v1alpha1"; do \
538544
(cd ../ && $(MAKE) clean-generated-openapi-definitions SRC_DIRS="./$${pkg}"); \
539545
echo "** Generating openapi schema for types in ./$${pkg} **"; \
540546
$(OPENAPI_GEN) \

Diff for: api/addons/v1beta1/clusterresourceset_types.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222

23-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
2424
)
2525

2626
// ClusterResourceSet's ResourcesApplied condition and corresponding reasons that will be used in v1Beta2 API version.
@@ -40,7 +40,7 @@ const (
4040
ResourcesAppliedWrongSecretTypeV1Beta2Reason = "WrongSecretType"
4141

4242
// ResourcesAppliedInternalErrorV1Beta2Reason surfaces unexpected failures when reconciling a ClusterResourceSet.
43-
ResourcesAppliedInternalErrorV1Beta2Reason = clusterv1.InternalErrorV1Beta2Reason
43+
ResourcesAppliedInternalErrorV1Beta2Reason = clusterv1beta1.InternalErrorV1Beta2Reason
4444
)
4545

4646
const (
@@ -125,7 +125,7 @@ type ClusterResourceSetStatus struct {
125125

126126
// conditions defines current state of the ClusterResourceSet.
127127
// +optional
128-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
128+
Conditions clusterv1beta1.Conditions `json:"conditions,omitempty"`
129129

130130
// v1beta2 groups all the fields that will be added or modified in ClusterResourceSet's status with the V1Beta2 version.
131131
// +optional
@@ -147,12 +147,12 @@ type ClusterResourceSetV1Beta2Status struct {
147147
// ANCHOR_END: ClusterResourceSetStatus
148148

149149
// GetConditions returns the set of conditions for this object.
150-
func (m *ClusterResourceSet) GetConditions() clusterv1.Conditions {
150+
func (m *ClusterResourceSet) GetConditions() clusterv1beta1.Conditions {
151151
return m.Status.Conditions
152152
}
153153

154154
// SetConditions sets the conditions on this object.
155-
func (m *ClusterResourceSet) SetConditions(conditions clusterv1.Conditions) {
155+
func (m *ClusterResourceSet) SetConditions(conditions clusterv1beta1.Conditions) {
156156
m.Status.Conditions = conditions
157157
}
158158

@@ -175,7 +175,7 @@ func (m *ClusterResourceSet) SetV1Beta2Conditions(conditions []metav1.Condition)
175175
// +kubebuilder:object:root=true
176176
// +kubebuilder:resource:path=clusterresourcesets,scope=Namespaced,categories=cluster-api
177177
// +kubebuilder:subresource:status
178-
// +kubebuilder:storageversion
178+
// +kubebuilder:deprecatedversion
179179
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterResourceSet"
180180

181181
// ClusterResourceSet is the Schema for the clusterresourcesets API.

Diff for: api/addons/v1beta1/clusterresourcesetbinding_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func referSameObject(a, b metav1.OwnerReference) bool {
175175
// +kubebuilder:object:root=true
176176
// +kubebuilder:resource:path=clusterresourcesetbindings,scope=Namespaced,categories=cluster-api
177177
// +kubebuilder:subresource:status
178-
// +kubebuilder:storageversion
178+
// +kubebuilder:deprecatedversion
179179
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterResourceSetBinding"
180180

181181
// ClusterResourceSetBinding lists all matching ClusterResourceSets with the cluster it belongs to.

Diff for: api/addons/v1beta1/condition_consts.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ limitations under the License.
1616

1717
package v1beta1
1818

19-
import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
19+
import (
20+
clusterv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
21+
)
2022

2123
// Conditions and condition Reasons for the ClusterResourceSet object.
2224
const (
2325
// ResourcesAppliedCondition documents that all resources in the ClusterResourceSet object are applied to
2426
// all matching clusters. This indicates all resources exist, and no errors during applying them to all clusters.
25-
ResourcesAppliedCondition clusterv1.ConditionType = "ResourcesApplied"
27+
ResourcesAppliedCondition clusterv1beta1.ConditionType = "ResourcesApplied"
2628

2729
// RemoteClusterClientFailedReason (Severity=Error) documents failure during getting the remote cluster client.
2830
RemoteClusterClientFailedReason = "RemoteClusterClientFailed"

Diff for: api/addons/v1beta1/conversion.go

+29-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,32 @@ limitations under the License.
1616

1717
package v1beta1
1818

19-
func (*ClusterResourceSet) Hub() {}
20-
func (*ClusterResourceSetList) Hub() {}
21-
func (*ClusterResourceSetBinding) Hub() {}
22-
func (*ClusterResourceSetBindingList) Hub() {}
19+
import (
20+
"sigs.k8s.io/controller-runtime/pkg/conversion"
21+
22+
addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2"
23+
)
24+
25+
func (src *ClusterResourceSet) ConvertTo(dstRaw conversion.Hub) error {
26+
dst := dstRaw.(*addonsv1.ClusterResourceSet)
27+
28+
return Convert_v1beta1_ClusterResourceSet_To_v1beta2_ClusterResourceSet(src, dst, nil)
29+
}
30+
31+
func (dst *ClusterResourceSet) ConvertFrom(srcRaw conversion.Hub) error {
32+
src := srcRaw.(*addonsv1.ClusterResourceSet)
33+
34+
return Convert_v1beta2_ClusterResourceSet_To_v1beta1_ClusterResourceSet(src, dst, nil)
35+
}
36+
37+
func (src *ClusterResourceSetBinding) ConvertTo(dstRaw conversion.Hub) error {
38+
dst := dstRaw.(*addonsv1.ClusterResourceSetBinding)
39+
40+
return Convert_v1beta1_ClusterResourceSetBinding_To_v1beta2_ClusterResourceSetBinding(src, dst, nil)
41+
}
42+
43+
func (dst *ClusterResourceSetBinding) ConvertFrom(srcRaw conversion.Hub) error {
44+
src := srcRaw.(*addonsv1.ClusterResourceSetBinding)
45+
46+
return Convert_v1beta2_ClusterResourceSetBinding_To_v1beta1_ClusterResourceSetBinding(src, dst, nil)
47+
}

Diff for: api/addons/v1beta1/conversion_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//go:build !race
2+
3+
/*
4+
Copyright 2025 The Kubernetes Authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package v1beta1
20+
21+
import (
22+
"testing"
23+
24+
addonsv1 "sigs.k8s.io/cluster-api/api/addons/v1beta2"
25+
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
26+
)
27+
28+
// Test is disabled when the race detector is enabled (via "//go:build !race" above) because otherwise the fuzz tests would just time out.
29+
30+
func TestFuzzyConversion(t *testing.T) {
31+
t.Run("for ClusterResourceSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
32+
Hub: &addonsv1.ClusterResourceSet{},
33+
Spoke: &ClusterResourceSet{},
34+
}))
35+
t.Run("for ClusterResourceSetBinding", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
36+
Hub: &addonsv1.ClusterResourceSetBinding{},
37+
Spoke: &ClusterResourceSetBinding{},
38+
}))
39+
}

Diff for: api/addons/v1beta1/doc.go

+4
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// Package v1beta1 contains API Schema definitions for the addons v1beta1 API group
18+
// +k8s:conversion-gen=sigs.k8s.io/cluster-api/api/addons/v1beta2
19+
// +kubebuilder:object:generate=true
20+
// +groupName=addons.cluster.x-k8s.io
1721
package v1beta1

Diff for: api/addons/v1beta1/groupversion_info.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1beta1 contains API Schema definitions for the addons v1beta1 API group
18-
// +kubebuilder:object:generate=true
19-
// +groupName=addons.cluster.x-k8s.io
2017
package v1beta1
2118

2219
import (
@@ -35,6 +32,9 @@ var (
3532
// AddToScheme adds the types in this group-version to the given scheme.
3633
AddToScheme = schemeBuilder.AddToScheme
3734

35+
// localSchemeBuilder is used for type conversions.
36+
localSchemeBuilder = schemeBuilder
37+
3838
objectTypes = []runtime.Object{}
3939
)
4040

0 commit comments

Comments
 (0)