Skip to content

Commit

Permalink
Merge pull request #3043 from jonathanbeber/backport_3037_07
Browse files Browse the repository at this point in the history
[backport 0.7] Fix AWSManagedControlPlane conversion
  • Loading branch information
k8s-ci-robot authored Dec 21, 2021
2 parents b23dce1 + 1a83292 commit ec1da9b
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions controlplane/eks/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,43 @@ import (
"sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1alpha4"
clusterapiapiv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterapiapiv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts the v1alpha3 AWSManagedControlPlane receiver to a v1alpha4 AWSManagedControlPlane.
func (r *AWSManagedControlPlane) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*v1alpha4.AWSManagedControlPlane)

return Convert_v1alpha3_AWSManagedControlPlane_To_v1alpha4_AWSManagedControlPlane(r, dst, nil)
if err := Convert_v1alpha3_AWSManagedControlPlane_To_v1alpha4_AWSManagedControlPlane(r, dst, nil); err != nil {
return err
}

restored := &v1alpha4.AWSManagedControlPlane{}
if ok, err := utilconversion.UnmarshalData(r, restored); err != nil || !ok {
return err
}

dst.Status.IdentityProviderStatus = restored.Status.IdentityProviderStatus
dst.Status.Bastion = restored.Status.Bastion
dst.Spec.OIDCIdentityProviderConfig = restored.Spec.OIDCIdentityProviderConfig

return nil
}

// ConvertFrom converts the v1alpha4 AWSManagedControlPlane receiver to a v1alpha3 AWSManagedControlPlane.
func (r *AWSManagedControlPlane) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*v1alpha4.AWSManagedControlPlane)

return Convert_v1alpha4_AWSManagedControlPlane_To_v1alpha3_AWSManagedControlPlane(src, r, nil)
if err := Convert_v1alpha4_AWSManagedControlPlane_To_v1alpha3_AWSManagedControlPlane(src, r, nil); err != nil {
return err
}

if err := utilconversion.MarshalData(src, r); err != nil {
return err
}

return nil
}

// ConvertTo converts the v1alpha3 AWSManagedControlPlaneList receiver to a v1alpha4 AWSManagedControlPlaneList.
Expand Down

0 comments on commit ec1da9b

Please sign in to comment.