Skip to content

Commit

Permalink
Merge pull request #1321 from CecileRobertMichon/storage-type-optional
Browse files Browse the repository at this point in the history
Make OSDisk Storage Type optional
  • Loading branch information
k8s-ci-robot authored Apr 27, 2021
2 parents c80f209 + a58e6a2 commit 57d8e61
Show file tree
Hide file tree
Showing 52 changed files with 286 additions and 323 deletions.
5 changes: 0 additions & 5 deletions api/v1alpha3/azurecluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ func Convert_v1alpha4_SecurityRule_To_v1alpha3_IngressRule(in *infrav1alpha4.Sec
return nil
}

// Convert_v1alpha4_ManagedDisk_To_v1alpha3_ManagedDisk converts between api versions
func Convert_v1alpha4_ManagedDisk_To_v1alpha3_ManagedDisk(in *infrav1alpha4.ManagedDisk, out *ManagedDisk, s apiconversion.Scope) error {
return autoConvert_v1alpha4_ManagedDisk_To_v1alpha3_ManagedDisk(in, out, s)
}

// Convert_v1alpha3_APIEndpoint_To_v1alpha4_APIEndpoint is an autogenerated conversion function.
func Convert_v1alpha3_APIEndpoint_To_v1alpha4_APIEndpoint(in *apiv1alpha3.APIEndpoint, out *apiv1alpha4.APIEndpoint, s apiconversion.Scope) error {
return apiv1alpha3.Convert_v1alpha3_APIEndpoint_To_v1alpha4_APIEndpoint(in, out, s)
Expand Down
52 changes: 52 additions & 0 deletions api/v1alpha3/azuremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ func (src *AzureMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
return err
}

// Handle special case for conversion of ManagedDisk to pointer.
if restored.Spec.OSDisk.ManagedDisk == nil && dst.Spec.OSDisk.ManagedDisk != nil {
if *dst.Spec.OSDisk.ManagedDisk == (v1alpha4.ManagedDiskParameters{}) {
// restore nil value if nothing has changed since conversion
dst.Spec.OSDisk.ManagedDisk = nil
}
}

return nil
}

Expand Down Expand Up @@ -101,3 +109,47 @@ func Convert_v1alpha4_AzureMachineStatus_To_v1alpha3_AzureMachineStatus(in *v1al

return nil
}

// Convert_v1alpha3_OSDisk_To_v1alpha4_OSDisk converts this OSDisk to the Hub version (v1alpha4).
func Convert_v1alpha3_OSDisk_To_v1alpha4_OSDisk(in *OSDisk, out *v1alpha4.OSDisk, s apiconversion.Scope) error { // nolint
if err := autoConvert_v1alpha3_OSDisk_To_v1alpha4_OSDisk(in, out, s); err != nil {
return err
}

out.ManagedDisk = &v1alpha4.ManagedDiskParameters{}
if err := Convert_v1alpha3_ManagedDisk_To_v1alpha4_ManagedDiskOptions(&in.ManagedDisk, out.ManagedDisk, s); err != nil {
return err
}

return nil
}

// Convert_v1alpha4_OSDisk_To_v1alpha3_OSDisk converts from the Hub version (v1alpha4) of the AzureMachineStatus to this version.
func Convert_v1alpha4_OSDisk_To_v1alpha3_OSDisk(in *v1alpha4.OSDisk, out *OSDisk, s apiconversion.Scope) error { // nolint
if err := autoConvert_v1alpha4_OSDisk_To_v1alpha3_OSDisk(in, out, s); err != nil {
return err
}

if in.ManagedDisk != nil {
out.ManagedDisk = ManagedDisk{}
if err := Convert_v1alpha4_ManagedDiskOptions_To_v1alpha3_ManagedDisk(in.ManagedDisk, &out.ManagedDisk, s); err != nil {
return err
}
}

return nil
}

// Convert_v1alpha3_ManagedDisk_To_v1alpha4_ManagedDiskOptions converts this ManagedDisk to the Hub version (v1alpha4).
func Convert_v1alpha3_ManagedDisk_To_v1alpha4_ManagedDiskOptions(in *ManagedDisk, out *v1alpha4.ManagedDiskParameters, s apiconversion.Scope) error { // nolint
out.StorageAccountType = in.StorageAccountType
out.DiskEncryptionSet = (*v1alpha4.DiskEncryptionSetParameters)(in.DiskEncryptionSet)
return nil
}

// Convert_v1alpha4_ManagedDiskOptions_To_v1alpha3_ManagedDisk converts from the Hub version (v1alpha4) of the ManagedDiskParameters to this version.
func Convert_v1alpha4_ManagedDiskOptions_To_v1alpha3_ManagedDisk(in *v1alpha4.ManagedDiskParameters, out *ManagedDisk, s apiconversion.Scope) error { // nolint
out.StorageAccountType = in.StorageAccountType
out.DiskEncryptionSet = (*DiskEncryptionSetParameters)(in.DiskEncryptionSet)
return nil
}
8 changes: 8 additions & 0 deletions api/v1alpha3/azuremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func (src *AzureMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { // nol
return err
}

// Handle special case for conversion of ManagedDisk to pointer.
if restored.Spec.Template.Spec.OSDisk.ManagedDisk == nil && dst.Spec.Template.Spec.OSDisk.ManagedDisk != nil {
if *dst.Spec.Template.Spec.OSDisk.ManagedDisk == (infrav1alpha4.ManagedDiskParameters{}) {
// restore nil value if nothing has changed since conversion
dst.Spec.Template.Spec.OSDisk.ManagedDisk = nil
}
}

return nil
}

Expand Down
107 changes: 15 additions & 92 deletions api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 57d8e61

Please sign in to comment.