From b78ccc4aa395bce28b9641d1e355c9871cbb27e2 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine Date: Tue, 23 Apr 2024 15:37:23 -0400 Subject: [PATCH] workaround for https://github.com/kubernetes/code-generator/issues/94 Signed-off-by: Ashley Dumaine --- controlplane/api/v1alpha1/conversion.go | 10 ++++++++++ .../api/v1alpha1/zz_generated.conversion.go | 20 +++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/controlplane/api/v1alpha1/conversion.go b/controlplane/api/v1alpha1/conversion.go index f7346ea2..8db5bebe 100644 --- a/controlplane/api/v1alpha1/conversion.go +++ b/controlplane/api/v1alpha1/conversion.go @@ -22,6 +22,8 @@ import ( apiconversion "k8s.io/apimachinery/pkg/conversion" utilconversion "sigs.k8s.io/cluster-api/util/conversion" + bootstrapv1beta1 "github.com/rancher/cluster-api-provider-rke2/bootstrap/api/v1beta1" + bootstrapv1alpha1 "github.com/rancher/cluster-api-provider-rke2/bootstrap/api/v1alpha1" controlplanev1 "github.com/rancher/cluster-api-provider-rke2/controlplane/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/conversion" ) @@ -202,3 +204,11 @@ func Convert_v1alpha1_RKE2ControlPlaneTemplateStatus_To_v1beta1_RKE2ControlPlane func Convert_v1beta1_RKE2ControlPlaneStatus_To_v1alpha1_RKE2ControlPlaneTemplateStatus(in *controlplanev1.RKE2ControlPlaneStatus, out *RKE2ControlPlaneTemplateStatus, s apiconversion.Scope) error { return nil } + +func Convert_v1beta1_RKE2ConfigSpec_To_v1alpha1_RKE2ConfigSpec(in *bootstrapv1beta1.RKE2ConfigSpec, out *bootstrapv1alpha1.RKE2ConfigSpec, s apiconversion.Scope) error { + return bootstrapv1alpha1.Convert_v1beta1_RKE2ConfigSpec_To_v1alpha1_RKE2ConfigSpec(in, out, s) +} + +func Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(in *bootstrapv1alpha1.RKE2ConfigSpec, out *bootstrapv1beta1.RKE2ConfigSpec, s apiconversion.Scope) error { + return bootstrapv1alpha1.Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(in, out, s) +} diff --git a/controlplane/api/v1alpha1/zz_generated.conversion.go b/controlplane/api/v1alpha1/zz_generated.conversion.go index acc2a5d2..6414cecb 100644 --- a/controlplane/api/v1alpha1/zz_generated.conversion.go +++ b/controlplane/api/v1alpha1/zz_generated.conversion.go @@ -156,6 +156,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*apiv1alpha1.RKE2ConfigSpec)(nil), (*apiv1beta1.RKE2ConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(a.(*apiv1alpha1.RKE2ConfigSpec), b.(*apiv1beta1.RKE2ConfigSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*RKE2ControlPlaneStatus)(nil), (*v1beta1.RKE2ControlPlaneStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha1_RKE2ControlPlaneStatus_To_v1beta1_RKE2ControlPlaneStatus(a.(*RKE2ControlPlaneStatus), b.(*v1beta1.RKE2ControlPlaneStatus), scope) }); err != nil { @@ -171,6 +176,11 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddConversionFunc((*apiv1beta1.RKE2ConfigSpec)(nil), (*apiv1alpha1.RKE2ConfigSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_RKE2ConfigSpec_To_v1alpha1_RKE2ConfigSpec(a.(*apiv1beta1.RKE2ConfigSpec), b.(*apiv1alpha1.RKE2ConfigSpec), scope) + }); err != nil { + return err + } if err := s.AddConversionFunc((*v1beta1.RKE2ControlPlaneSpec)(nil), (*RKE2ControlPlaneSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1beta1_RKE2ControlPlaneSpec_To_v1alpha1_RKE2ControlPlaneSpec(a.(*v1beta1.RKE2ControlPlaneSpec), b.(*RKE2ControlPlaneSpec), scope) }); err != nil { @@ -381,8 +391,9 @@ func Convert_v1beta1_RKE2ControlPlaneList_To_v1alpha1_RKE2ControlPlaneList(in *v } func autoConvert_v1alpha1_RKE2ControlPlaneSpec_To_v1beta1_RKE2ControlPlaneSpec(in *RKE2ControlPlaneSpec, out *v1beta1.RKE2ControlPlaneSpec, s conversion.Scope) error { - // FIXME: Provide conversion function to convert apiv1alpha1.RKE2ConfigSpec to apiv1beta1.RKE2ConfigSpec - compileErrorOnMissingConversion() + if err := Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(&in.RKE2ConfigSpec, &out.RKE2ConfigSpec, s); err != nil { + return err + } out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) if err := Convert_v1alpha1_RKE2ServerConfig_To_v1beta1_RKE2ServerConfig(&in.ServerConfig, &out.ServerConfig, s); err != nil { return err @@ -402,8 +413,9 @@ func Convert_v1alpha1_RKE2ControlPlaneSpec_To_v1beta1_RKE2ControlPlaneSpec(in *R } func autoConvert_v1beta1_RKE2ControlPlaneSpec_To_v1alpha1_RKE2ControlPlaneSpec(in *v1beta1.RKE2ControlPlaneSpec, out *RKE2ControlPlaneSpec, s conversion.Scope) error { - // FIXME: Provide conversion function to convert apiv1beta1.RKE2ConfigSpec to apiv1alpha1.RKE2ConfigSpec - compileErrorOnMissingConversion() + if err := Convert_v1beta1_RKE2ConfigSpec_To_v1alpha1_RKE2ConfigSpec(&in.RKE2ConfigSpec, &out.RKE2ConfigSpec, s); err != nil { + return err + } out.Replicas = (*int32)(unsafe.Pointer(in.Replicas)) // WARNING: in.Version requires manual conversion: does not exist in peer-type // WARNING: in.MachineTemplate requires manual conversion: does not exist in peer-type