From 696fccff7744e1b5de5194e3a475fc165ef9c601 Mon Sep 17 00:00:00 2001 From: Rory Z <16801068+Rory-Z@users.noreply.github.com> Date: Sat, 29 Jul 2023 12:01:06 +0800 Subject: [PATCH] fix(v2beta1): fix rebalane conversion webhook error --- apis/apps/v1beta4/rebalance_conversion.go | 2 ++ apis/apps/v1beta4/rebalance_conversion_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apis/apps/v1beta4/rebalance_conversion.go b/apis/apps/v1beta4/rebalance_conversion.go index b81b05e84..fb2c34658 100644 --- a/apis/apps/v1beta4/rebalance_conversion.go +++ b/apis/apps/v1beta4/rebalance_conversion.go @@ -36,6 +36,7 @@ func (src *Rebalance) ConvertTo(dstRaw conversion.Hub) error { return err } + dst.SetGroupVersionKind(v2beta1.GroupVersion.WithKind("Rebalance")) dst.Spec.InstanceKind = "EMQX" // +kubebuilder:docs-gen:collapse=rote conversion @@ -54,6 +55,7 @@ func (dst *Rebalance) ConvertFrom(srcRaw conversion.Hub) error { if err := json.Unmarshal(b, dst); err != nil { return err } + dst.SetGroupVersionKind(GroupVersion.WithKind("Rebalance")) // +kubebuilder:docs-gen:collapse=rote conversion return nil diff --git a/apis/apps/v1beta4/rebalance_conversion_test.go b/apis/apps/v1beta4/rebalance_conversion_test.go index 496ee4c8b..3da2e50c8 100644 --- a/apis/apps/v1beta4/rebalance_conversion_test.go +++ b/apis/apps/v1beta4/rebalance_conversion_test.go @@ -28,6 +28,7 @@ func TestConvertTo(t *testing.T) { src := &Rebalance{} assert.Nil(t, src.ConvertTo(dst)) + assert.Equal(t, v2beta1.GroupVersion.Version, dst.GetObjectKind().GroupVersionKind().Version) } func TestConvertFrom(t *testing.T) { @@ -35,4 +36,5 @@ func TestConvertFrom(t *testing.T) { src := &v2beta1.Rebalance{} assert.Nil(t, dst.ConvertFrom(src)) + assert.Equal(t, GroupVersion.Version, dst.GetObjectKind().GroupVersionKind().Version) }