Skip to content

Commit

Permalink
fix(v2beta1): fix rebalane conversion webhook error
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Jul 29, 2023
1 parent b064251 commit 696fccf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/apps/v1beta4/rebalance_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions apis/apps/v1beta4/rebalance_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ 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) {
dst := &Rebalance{}
src := &v2beta1.Rebalance{}

assert.Nil(t, dst.ConvertFrom(src))
assert.Equal(t, GroupVersion.Version, dst.GetObjectKind().GroupVersionKind().Version)
}

0 comments on commit 696fccf

Please sign in to comment.