Skip to content

Commit 0acdefd

Browse files
committed
use v1beta2 in runtime extension
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent 140fd29 commit 0acdefd

File tree

1 file changed

+23
-23
lines changed
  • test/extension/handlers/topologymutation

1 file changed

+23
-23
lines changed

test/extension/handlers/topologymutation/handler.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ import (
3333
intstrutil "k8s.io/apimachinery/pkg/util/intstr"
3434
ctrl "sigs.k8s.io/controller-runtime"
3535

36-
bootstrapv1beta1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta1"
37-
controlplanev1beta1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta1"
36+
bootstrapv1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta2"
37+
controlplanev1 "sigs.k8s.io/cluster-api/api/controlplane/kubeadm/v1beta2"
3838
clusterv1beta1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
3939
runtimehooksv1 "sigs.k8s.io/cluster-api/api/runtime/hooks/v1alpha1"
4040
"sigs.k8s.io/cluster-api/exp/runtime/topologymutation"
41-
infrav1beta1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
42-
infraexpv1beta1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta1"
41+
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta2"
42+
infraexpv1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/exp/api/v1beta2"
4343
"sigs.k8s.io/cluster-api/test/infrastructure/kind"
4444
)
4545

@@ -57,16 +57,16 @@ type ExtensionHandlers struct {
5757
// NewExtensionHandlers returns a new ExtensionHandlers for the topology mutation hook handlers.
5858
func NewExtensionHandlers() *ExtensionHandlers {
5959
scheme := runtime.NewScheme()
60-
_ = infrav1beta1.AddToScheme(scheme)
61-
_ = infraexpv1beta1.AddToScheme(scheme)
62-
_ = bootstrapv1beta1.AddToScheme(scheme)
63-
_ = controlplanev1beta1.AddToScheme(scheme)
60+
_ = infrav1.AddToScheme(scheme)
61+
_ = infraexpv1.AddToScheme(scheme)
62+
_ = bootstrapv1.AddToScheme(scheme)
63+
_ = controlplanev1.AddToScheme(scheme)
6464
return &ExtensionHandlers{
6565
// Add the apiGroups being handled to the decoder
6666
decoder: serializer.NewCodecFactory(scheme).UniversalDecoder(
67-
infrav1beta1.GroupVersion,
68-
bootstrapv1beta1.GroupVersion,
69-
controlplanev1beta1.GroupVersion,
67+
infrav1.GroupVersion,
68+
bootstrapv1.GroupVersion,
69+
controlplanev1.GroupVersion,
7070
),
7171
}
7272
}
@@ -87,18 +87,18 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
8787
log := ctrl.LoggerFrom(ctx)
8888

8989
switch obj := obj.(type) {
90-
case *infrav1beta1.DockerClusterTemplate:
90+
case *infrav1.DockerClusterTemplate:
9191
if err := patchDockerClusterTemplate(ctx, obj, variables); err != nil {
9292
log.Error(err, "Error patching DockerClusterTemplate")
9393
return errors.Wrap(err, "error patching DockerClusterTemplate")
9494
}
95-
case *controlplanev1beta1.KubeadmControlPlaneTemplate:
95+
case *controlplanev1.KubeadmControlPlaneTemplate:
9696
err := patchKubeadmControlPlaneTemplate(ctx, obj, variables)
9797
if err != nil {
9898
log.Error(err, "Error patching KubeadmControlPlaneTemplate")
9999
return errors.Wrapf(err, "error patching KubeadmControlPlaneTemplate")
100100
}
101-
case *bootstrapv1beta1.KubeadmConfigTemplate:
101+
case *bootstrapv1.KubeadmConfigTemplate:
102102
// NOTE: KubeadmConfigTemplate could be linked to one or more of the existing MachineDeployment class;
103103
// the patchKubeadmConfigTemplate func shows how to implement patches only for KubeadmConfigTemplates
104104
// linked to a specific MachineDeployment class; another option is to check the holderRef value and call
@@ -107,7 +107,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
107107
log.Error(err, "Error patching KubeadmConfigTemplate")
108108
return errors.Wrap(err, "error patching KubeadmConfigTemplate")
109109
}
110-
case *infrav1beta1.DockerMachineTemplate:
110+
case *infrav1.DockerMachineTemplate:
111111
// NOTE: DockerMachineTemplate could be linked to the ControlPlane or one or more of the existing MachineDeployment class;
112112
// the patchDockerMachineTemplate func shows how to implement different patches for DockerMachineTemplate
113113
// linked to ControlPlane or for DockerMachineTemplate linked to MachineDeployment classes; another option
@@ -116,7 +116,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
116116
log.Error(err, "Error patching DockerMachineTemplate")
117117
return errors.Wrap(err, "error patching DockerMachineTemplate")
118118
}
119-
case *infraexpv1beta1.DockerMachinePoolTemplate:
119+
case *infraexpv1.DockerMachinePoolTemplate:
120120
if err := patchDockerMachinePoolTemplate(ctx, obj, variables); err != nil {
121121
log.Error(err, "Error patching DockerMachinePoolTemplate")
122122
return errors.Wrap(err, "error patching DockerMachinePoolTemplate")
@@ -129,7 +129,7 @@ func (h *ExtensionHandlers) GeneratePatches(ctx context.Context, req *runtimehoo
129129
// patchDockerClusterTemplate patches the DockerClusterTemplate.
130130
// It sets the LoadBalancer.ImageRepository if the imageRepository variable is provided.
131131
// NOTE: this patch is not required for any special reason, it is used for testing the patch machinery itself.
132-
func patchDockerClusterTemplate(_ context.Context, dockerClusterTemplate *infrav1beta1.DockerClusterTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
132+
func patchDockerClusterTemplate(_ context.Context, dockerClusterTemplate *infrav1.DockerClusterTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
133133
imageRepo, err := topologymutation.GetStringVariable(templateVariables, "imageRepository")
134134
if err != nil {
135135
if topologymutation.IsNotFoundError(err) {
@@ -146,7 +146,7 @@ func patchDockerClusterTemplate(_ context.Context, dockerClusterTemplate *infrav
146146
// patchKubeadmControlPlaneTemplate patches the ControlPlaneTemplate.
147147
// It sets the RolloutStrategy.RollingUpdate.MaxSurge if the kubeadmControlPlaneMaxSurge is provided.
148148
// NOTE: RolloutStrategy.RollingUpdate.MaxSurge patch is not required for any special reason, it is used for testing the patch machinery itself.
149-
func patchKubeadmControlPlaneTemplate(ctx context.Context, kcpTemplate *controlplanev1beta1.KubeadmControlPlaneTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
149+
func patchKubeadmControlPlaneTemplate(ctx context.Context, kcpTemplate *controlplanev1.KubeadmControlPlaneTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
150150
log := ctrl.LoggerFrom(ctx)
151151

152152
// 1) Patch RolloutStrategy RollingUpdate MaxSurge with the value from the Cluster Topology variable.
@@ -163,17 +163,17 @@ func patchKubeadmControlPlaneTemplate(ctx context.Context, kcpTemplate *controlp
163163
kubeadmControlPlaneMaxSurgeIntOrString := intstrutil.Parse(kcpControlPlaneMaxSurge)
164164
log.Info(fmt.Sprintf("Setting KubeadmControlPlaneMaxSurge to %q", kubeadmControlPlaneMaxSurgeIntOrString.String()))
165165
if kcpTemplate.Spec.Template.Spec.RolloutStrategy == nil {
166-
kcpTemplate.Spec.Template.Spec.RolloutStrategy = &controlplanev1beta1.RolloutStrategy{}
166+
kcpTemplate.Spec.Template.Spec.RolloutStrategy = &controlplanev1.RolloutStrategy{}
167167
}
168168
if kcpTemplate.Spec.Template.Spec.RolloutStrategy.RollingUpdate == nil {
169-
kcpTemplate.Spec.Template.Spec.RolloutStrategy.RollingUpdate = &controlplanev1beta1.RollingUpdate{}
169+
kcpTemplate.Spec.Template.Spec.RolloutStrategy.RollingUpdate = &controlplanev1.RollingUpdate{}
170170
}
171171
kcpTemplate.Spec.Template.Spec.RolloutStrategy.RollingUpdate.MaxSurge = &kubeadmControlPlaneMaxSurgeIntOrString
172172
return nil
173173
}
174174

175175
// patchKubeadmConfigTemplate patches the ControlPlaneTemplate.
176-
func patchKubeadmConfigTemplate(_ context.Context, _ *bootstrapv1beta1.KubeadmConfigTemplate, _ map[string]apiextensionsv1.JSON) error {
176+
func patchKubeadmConfigTemplate(_ context.Context, _ *bootstrapv1.KubeadmConfigTemplate, _ map[string]apiextensionsv1.JSON) error {
177177
return nil
178178
}
179179

@@ -182,7 +182,7 @@ func patchKubeadmConfigTemplate(_ context.Context, _ *bootstrapv1beta1.KubeadmCo
182182
// the DockerMachineTemplate belongs to.
183183
// NOTE: this patch is not required anymore after the introduction of the kind mapper in kind, however we keep it
184184
// as example of version aware patches.
185-
func patchDockerMachineTemplate(ctx context.Context, dockerMachineTemplate *infrav1beta1.DockerMachineTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
185+
func patchDockerMachineTemplate(ctx context.Context, dockerMachineTemplate *infrav1.DockerMachineTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
186186
log := ctrl.LoggerFrom(ctx)
187187

188188
// If the DockerMachineTemplate belongs to the ControlPlane, set the images using the ControlPlane version.
@@ -237,7 +237,7 @@ func patchDockerMachineTemplate(ctx context.Context, dockerMachineTemplate *infr
237237
// It sets the CustomImage to an image for the version in use by the MachinePool.
238238
// NOTE: this patch is not required anymore after the introduction of the kind mapper in kind, however we keep it
239239
// as example of version aware patches.
240-
func patchDockerMachinePoolTemplate(ctx context.Context, dockerMachinePoolTemplate *infraexpv1beta1.DockerMachinePoolTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
240+
func patchDockerMachinePoolTemplate(ctx context.Context, dockerMachinePoolTemplate *infraexpv1.DockerMachinePoolTemplate, templateVariables map[string]apiextensionsv1.JSON) error {
241241
log := ctrl.LoggerFrom(ctx)
242242

243243
// If the DockerMachinePoolTemplate belongs to a MachinePool, set the images the MachinePool version.

0 commit comments

Comments
 (0)