Skip to content

Commit 33a66e3

Browse files
committed
Fix APIVersion in conversion logic
1 parent 99ad454 commit 33a66e3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

apis/core/v1beta1/openstackcontrolplane_conversion.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ func (src *OpenStackControlPlane) ConvertTo(dstRaw conversion.Hub) error {
4646
return fmt.Errorf("failed to unmarshal into v1beta2 object: %w", err)
4747
}
4848

49+
// Fix the APIVersion to ensure it's set to v1beta2
50+
if dst, ok := dstRaw.(interface{ SetAPIVersion(string) }); ok {
51+
dst.SetAPIVersion("core.openstack.org/v1beta2")
52+
} else {
53+
// Use reflection to set the APIVersion field directly
54+
dstValue := reflect.ValueOf(dstRaw).Elem()
55+
if apiVersionField := dstValue.FieldByName("APIVersion"); apiVersionField.IsValid() && apiVersionField.CanSet() {
56+
apiVersionField.SetString("core.openstack.org/v1beta2")
57+
}
58+
}
59+
4960
// Handle Keystone-specific conversions that need special attention
5061
if err := src.convertKeystoneTemplateSpecifics(dstRaw); err != nil {
5162
return fmt.Errorf("failed to convert Keystone template: %w", err)
@@ -71,6 +82,9 @@ func (dst *OpenStackControlPlane) ConvertFrom(srcRaw conversion.Hub) error {
7182
return fmt.Errorf("failed to unmarshal into v1beta1 object: %w", err)
7283
}
7384

85+
// Fix the APIVersion to ensure it's set to v1beta1
86+
dst.APIVersion = "core.openstack.org/v1beta1"
87+
7488
// Handle Keystone-specific conversions that need special attention
7589
if err := dst.convertKeystoneTemplateSpecificsFrom(srcRaw); err != nil {
7690
return fmt.Errorf("failed to convert Keystone template from v1beta2: %w", err)

0 commit comments

Comments
 (0)