Skip to content

Commit 8486a1e

Browse files
committed
Cleanup CAPD exp packages
Signed-off-by: Stefan Büringer [email protected]
1 parent 5857f3f commit 8486a1e

Some content is hidden

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

63 files changed

+2139
-3039
lines changed

Makefile

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,6 @@ generate-manifests-docker-infrastructure: $(CONTROLLER_GEN) ## Generate manifest
370370
cd $(CAPD_DIR); $(CONTROLLER_GEN) \
371371
paths=./ \
372372
paths=./api/... \
373-
paths=./exp/api/... \
374-
paths=./exp/internal/controllers/... \
375-
paths=./exp/internal/webhooks/... \
376373
paths=./internal/controllers/... \
377374
paths=./internal/webhooks/... \
378375
crd:crdVersions=v1 \
@@ -430,11 +427,10 @@ generate-go-deepcopy-kubeadm-control-plane: $(CONTROLLER_GEN) ## Generate deepco
430427

431428
.PHONY: generate-go-deepcopy-docker-infrastructure
432429
generate-go-deepcopy-docker-infrastructure: $(CONTROLLER_GEN) generate-go-deepcopy-in-memory-infrastructure ## Generate deepcopy go code for docker infrastructure provider
433-
$(MAKE) clean-generated-deepcopy SRC_DIRS="$(CAPD_DIR)/api,$(CAPD_DIR)/exp/api"
430+
$(MAKE) clean-generated-deepcopy SRC_DIRS="$(CAPD_DIR)/api"
434431
cd $(CAPD_DIR); $(CONTROLLER_GEN) \
435432
object:headerFile=../../../hack/boilerplate/boilerplate.generatego.txt \
436-
paths=./api/... \
437-
paths=./exp/api/...
433+
paths=./api/...
438434

439435
.PHONY: generate-go-deepcopy-in-memory-infrastructure
440436
generate-go-deepcopy-in-memory-infrastructure: $(CONTROLLER_GEN) ## Generate deepcopy go code for in-memory cloud resources
@@ -534,10 +530,7 @@ generate-go-conversions-docker-infrastructure: $(CONVERSION_GEN) ## Generate con
534530
--go-header-file=../../../hack/boilerplate/boilerplate.generatego.txt \
535531
./api/v1alpha3 \
536532
./api/v1alpha4 \
537-
./api/v1beta1 \
538-
./exp/api/v1alpha3 \
539-
./exp/api/v1alpha4 \
540-
./exp/api/v1beta1
533+
./api/v1beta1
541534

542535
.PHONY: generate-go-conversions-test-extension
543536
generate-go-conversions-test-extension: $(CONVERSION_GEN) ## Generate conversions go code for test runtime extension provider
@@ -729,7 +722,6 @@ verify-conversions: $(CONVERSION_VERIFIER) ## Verifies expected API conversion
729722
./api/... \
730723
./internal/api/... \
731724
./test/infrastructure/docker/api/... \
732-
./test/infrastructure/docker/exp/api/...
733725

734726
.PHONY: verify-doctoc
735727
verify-doctoc: generate-doctoc

test/extension/handlers/topologymutation/handler.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import (
4343
"sigs.k8s.io/cluster-api/exp/runtime/topologymutation"
4444
infrav1beta1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
4545
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta2"
46-
infraexpv1beta1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
47-
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta2"
4846
"sigs.k8s.io/cluster-api/test/infrastructure/kind"
4947
)
5048

@@ -64,8 +62,6 @@ func NewExtensionHandlers() *ExtensionHandlers {
6462
scheme := runtime.NewScheme()
6563
_ = infrav1beta1.AddToScheme(scheme)
6664
_ = infrav1.AddToScheme(scheme)
67-
_ = infraexpv1beta1.AddToScheme(scheme)
68-
_ = infraexpv1.AddToScheme(scheme)
6965
_ = bootstrapv1beta1.AddToScheme(scheme)
7066
_ = bootstrapv1.AddToScheme(scheme)
7167
_ = controlplanev1beta1.AddToScheme(scheme)
@@ -125,7 +121,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
125121
log.Error(err, "Error patching DockerMachineTemplate")
126122
return errors.Wrap(err, "error patching DockerMachineTemplate")
127123
}
128-
case *infraexpv1beta1.DockerMachinePoolTemplate, *infraexpv1.DockerMachinePoolTemplate:
124+
case *infrav1beta1.DockerMachinePoolTemplate, *infrav1.DockerMachinePoolTemplate:
129125
if err := patchDockerMachinePoolTemplate(ctx, obj, variables); err != nil {
130126
log.Error(err, "Error patching DockerMachinePoolTemplate")
131127
return errors.Wrap(err, "error patching DockerMachinePoolTemplate")
@@ -370,12 +366,12 @@ func patchDockerMachinePoolTemplate(ctx context.Context, obj runtime.Object, tem
370366

371367
log.Info(fmt.Sprintf("Setting MachinePool customImage to %q", kindMapping.Image))
372368

373-
dockerMachinePoolTemplateV1Beta1, ok := obj.(*infraexpv1beta1.DockerMachinePoolTemplate)
369+
dockerMachinePoolTemplateV1Beta1, ok := obj.(*infrav1beta1.DockerMachinePoolTemplate)
374370
if ok {
375371
dockerMachinePoolTemplateV1Beta1.Spec.Template.Spec.Template.CustomImage = kindMapping.Image
376372
}
377373

378-
dockerMachinePoolTemplate, ok := obj.(*infraexpv1.DockerMachinePoolTemplate)
374+
dockerMachinePoolTemplate, ok := obj.(*infrav1.DockerMachinePoolTemplate)
379375
if ok {
380376
dockerMachinePoolTemplate.Spec.Template.Spec.Template.CustomImage = kindMapping.Image
381377
}

test/extension/handlers/topologymutation/handler_test.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
3636
runtimehooksv1 "sigs.k8s.io/cluster-api/api/runtime/hooks/v1alpha1"
3737
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta2"
38-
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta2"
3938
)
4039

4140
var (
@@ -44,7 +43,6 @@ var (
4443

4544
func init() {
4645
_ = infrav1.AddToScheme(testScheme)
47-
_ = infraexpv1.AddToScheme(testScheme)
4846
_ = controlplanev1.AddToScheme(testScheme)
4947
_ = bootstrapv1.AddToScheme(testScheme)
5048
}
@@ -250,21 +248,21 @@ func Test_patchDockerMachinePoolTemplate(t *testing.T) {
250248

251249
tests := []struct {
252250
name string
253-
template *infraexpv1.DockerMachinePoolTemplate
251+
template *infrav1.DockerMachinePoolTemplate
254252
variables map[string]apiextensionsv1.JSON
255-
expectedTemplate *infraexpv1.DockerMachinePoolTemplate
253+
expectedTemplate *infrav1.DockerMachinePoolTemplate
256254
expectedErr bool
257255
}{
258256
{
259257
name: "fails if builtin.controlPlane.version nor builtin.machinePool.version is not set",
260-
template: &infraexpv1.DockerMachinePoolTemplate{},
258+
template: &infrav1.DockerMachinePoolTemplate{},
261259
variables: nil,
262-
expectedTemplate: &infraexpv1.DockerMachinePoolTemplate{},
260+
expectedTemplate: &infrav1.DockerMachinePoolTemplate{},
263261
expectedErr: true,
264262
},
265263
{
266264
name: "sets customImage for templates linked to ControlPlane",
267-
template: &infraexpv1.DockerMachinePoolTemplate{},
265+
template: &infrav1.DockerMachinePoolTemplate{},
268266
variables: map[string]apiextensionsv1.JSON{
269267
runtimehooksv1.BuiltinsName: {Raw: toJSON(runtimehooksv1.Builtins{
270268
ControlPlane: &runtimehooksv1.ControlPlaneBuiltins{
@@ -276,11 +274,11 @@ func Test_patchDockerMachinePoolTemplate(t *testing.T) {
276274
},
277275
})},
278276
},
279-
expectedTemplate: &infraexpv1.DockerMachinePoolTemplate{
280-
Spec: infraexpv1.DockerMachinePoolTemplateSpec{
281-
Template: infraexpv1.DockerMachinePoolTemplateResource{
282-
Spec: infraexpv1.DockerMachinePoolSpec{
283-
Template: infraexpv1.DockerMachinePoolMachineTemplate{
277+
expectedTemplate: &infrav1.DockerMachinePoolTemplate{
278+
Spec: infrav1.DockerMachinePoolTemplateSpec{
279+
Template: infrav1.DockerMachinePoolTemplateResource{
280+
Spec: infrav1.DockerMachinePoolSpec{
281+
Template: infrav1.DockerMachinePoolMachineTemplate{
284282
CustomImage: "kindest/node:v1.23.0",
285283
},
286284
},
@@ -346,7 +344,7 @@ func TestHandler_GeneratePatches(t *testing.T) {
346344
APIVersion: infrav1.GroupVersion.String(),
347345
},
348346
}
349-
dockerMachinePoolTemplate := infraexpv1.DockerMachinePoolTemplate{
347+
dockerMachinePoolTemplate := infrav1.DockerMachinePoolTemplate{
350348
TypeMeta: metav1.TypeMeta{
351349
Kind: "DockerMachinePoolTemplate",
352350
APIVersion: infrav1.GroupVersion.String(),

test/framework/finalizers_helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
3636
clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
3737
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta2"
38-
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta2"
3938
"sigs.k8s.io/cluster-api/util/patch"
4039
)
4140

@@ -72,7 +71,7 @@ var ExpFinalizersAssertion = map[string]func(types.NamespacedName) []string{
7271
var DockerInfraFinalizersAssertion = map[string]func(types.NamespacedName) []string{
7372
dockerMachineKind: func(_ types.NamespacedName) []string { return []string{infrav1.MachineFinalizer} },
7473
dockerClusterKind: func(_ types.NamespacedName) []string { return []string{infrav1.ClusterFinalizer} },
75-
dockerMachinePoolKind: func(_ types.NamespacedName) []string { return []string{infraexpv1.MachinePoolFinalizer} },
74+
dockerMachinePoolKind: func(_ types.NamespacedName) []string { return []string{infrav1.MachinePoolFinalizer} },
7675
}
7776

7877
// KubeadmControlPlaneFinalizersAssertion maps Kubeadm resource types to their expected finalizers.

test/framework/ownerreference_helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
4040
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
4141
clusterctlcluster "sigs.k8s.io/cluster-api/cmd/clusterctl/client/cluster"
42-
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta2"
42+
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta2"
4343
"sigs.k8s.io/cluster-api/util/patch"
4444
)
4545

@@ -301,7 +301,7 @@ var (
301301
dockerClusterKind = "DockerCluster"
302302
dockerClusterTemplateKind = "DockerClusterTemplate"
303303

304-
dockerMachinePoolController = metav1.OwnerReference{Kind: dockerMachinePoolKind, APIVersion: infraexpv1.GroupVersion.String()}
304+
dockerMachinePoolController = metav1.OwnerReference{Kind: dockerMachinePoolKind, APIVersion: infrav1.GroupVersion.String()}
305305
)
306306

307307
// DockerInfraOwnerReferenceAssertions maps Docker Infrastructure types to functions which return an error if the passed

test/infrastructure/docker/api/v1alpha3/conversion.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,55 @@ func Convert_v1alpha3_DockerClusterSpec_To_v1beta2_DockerClusterSpec(in *DockerC
355355
func Convert_v1beta2_DockerMachineTemplate_To_v1alpha3_DockerMachineTemplate(in *infrav1.DockerMachineTemplate, out *DockerMachineTemplate, s apiconversion.Scope) error {
356356
return autoConvert_v1beta2_DockerMachineTemplate_To_v1alpha3_DockerMachineTemplate(in, out, s)
357357
}
358+
359+
func (src *DockerMachinePool) ConvertTo(dstRaw conversion.Hub) error {
360+
dst := dstRaw.(*infrav1.DockerMachinePool)
361+
362+
if err := Convert_v1alpha3_DockerMachinePool_To_v1beta2_DockerMachinePool(src, dst, nil); err != nil {
363+
return err
364+
}
365+
366+
// Reset conditions from autogenerated conversions
367+
// NOTE: v1beta3 conditions should not be automatically be converted into v1beta2 conditions.
368+
dst.Status.Conditions = nil
369+
if src.Status.Conditions != nil {
370+
dst.Status.Deprecated = &infrav1.DockerMachinePoolDeprecatedStatus{}
371+
dst.Status.Deprecated.V1Beta1 = &infrav1.DockerMachinePoolV1Beta1DeprecatedStatus{}
372+
clusterv1alpha3.Convert_v1alpha3_Conditions_To_v1beta2_Deprecated_V1Beta1_Conditions(&src.Status.Conditions, &dst.Status.Deprecated.V1Beta1.Conditions)
373+
}
374+
375+
// Manually restore data.
376+
restored := &infrav1.DockerMachinePool{}
377+
if ok, err := utilconversion.UnmarshalData(src, restored); err != nil || !ok {
378+
return err
379+
}
380+
381+
dst.Status.InfrastructureMachineKind = restored.Status.InfrastructureMachineKind
382+
dst.Status.Conditions = restored.Status.Conditions
383+
384+
return nil
385+
}
386+
387+
func (dst *DockerMachinePool) ConvertFrom(srcRaw conversion.Hub) error {
388+
src := srcRaw.(*infrav1.DockerMachinePool)
389+
390+
if err := Convert_v1beta2_DockerMachinePool_To_v1alpha3_DockerMachinePool(src, dst, nil); err != nil {
391+
return err
392+
}
393+
394+
// Reset conditions from autogenerated conversions
395+
// NOTE: v1beta2 conditions should not be automatically be converted into v1alpha3 conditions.
396+
dst.Status.Conditions = nil
397+
if src.Status.Deprecated != nil && src.Status.Deprecated.V1Beta1 != nil && src.Status.Deprecated.V1Beta1.Conditions != nil {
398+
clusterv1alpha3.Convert_v1beta2_Deprecated_V1Beta1_Conditions_To_v1alpha3_Conditions(&src.Status.Deprecated.V1Beta1.Conditions, &dst.Status.Conditions)
399+
}
400+
401+
// Preserve Hub data on down-conversion except for metadata
402+
return utilconversion.MarshalData(src, dst)
403+
}
404+
405+
// Convert_v1beta2_DockerMachinePoolStatus_To_v1alpha3_DockerMachinePoolStatus is an autogenerated conversion function.
406+
func Convert_v1beta2_DockerMachinePoolStatus_To_v1alpha3_DockerMachinePoolStatus(in *infrav1.DockerMachinePoolStatus, out *DockerMachinePoolStatus, s apiconversion.Scope) error {
407+
// NOTE: custom conversion func is required because Status.InfrastructureMachineKind has been added in v1beta1.
408+
return autoConvert_v1beta2_DockerMachinePoolStatus_To_v1alpha3_DockerMachinePoolStatus(in, out, s)
409+
}

test/infrastructure/docker/api/v1alpha3/conversion_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func TestFuzzyConversion(t *testing.T) {
5252
Spoke: &DockerMachineTemplate{},
5353
FuzzerFuncs: []fuzzer.FuzzerFuncs{DockerMachineTemplateFuzzFunc},
5454
}))
55+
t.Run("for DockerMachinePool", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
56+
Hub: &infrav1.DockerMachinePool{},
57+
Spoke: &DockerMachinePool{},
58+
FuzzerFuncs: []fuzzer.FuzzerFuncs{DockerMachinePoolFuzzFunc},
59+
}))
5560
}
5661

5762
func DockerClusterFuzzFunc(_ runtimeserializer.CodecFactory) []any {
@@ -109,3 +114,19 @@ func DockerMachineTemplateFuzzFunc(_ runtimeserializer.CodecFactory) []any {
109114
spokeDockerMachineSpec,
110115
}
111116
}
117+
118+
func DockerMachinePoolFuzzFunc(_ runtimeserializer.CodecFactory) []any {
119+
return []any{
120+
hubDockerMachinePoolStatus,
121+
}
122+
}
123+
124+
func hubDockerMachinePoolStatus(in *infrav1.DockerMachinePoolStatus, c randfill.Continue) {
125+
c.FillNoCustom(in)
126+
127+
if in.Deprecated != nil {
128+
if in.Deprecated.V1Beta1 == nil || reflect.DeepEqual(in.Deprecated.V1Beta1, &infrav1.DockerMachinePoolV1Beta1DeprecatedStatus{}) {
129+
in.Deprecated = nil
130+
}
131+
}
132+
}

test/infrastructure/docker/exp/api/v1alpha3/dockermachinepool_types.go renamed to test/infrastructure/docker/api/v1alpha3/dockermachinepool_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

2222
clusterv1alpha3 "sigs.k8s.io/cluster-api/internal/api/core/v1alpha3"
23-
infrav1alpha3 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1alpha3"
2423
)
2524

2625
const (
@@ -43,7 +42,7 @@ type DockerMachinePoolMachineTemplate struct {
4342
// ExtraMounts describes additional mount points for the node container
4443
// These may be used to bind a hostPath
4544
// +optional
46-
ExtraMounts []infrav1alpha3.Mount `json:"extraMounts,omitempty"`
45+
ExtraMounts []Mount `json:"extraMounts,omitempty"`
4746
}
4847

4948
// DockerMachinePoolSpec defines the desired state of DockerMachinePool.

0 commit comments

Comments
 (0)