From f74f64b9408f80e0df156329f3db035ddf0cbd0c Mon Sep 17 00:00:00 2001 From: Anuj Gupta Date: Mon, 6 Jan 2025 15:59:01 +0530 Subject: [PATCH] Fix --- upup/pkg/fi/cloudup/azuretasks/disk.go | 15 +++++++++------ upup/pkg/fi/cloudup/azuretasks/disk_test.go | 11 +++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/upup/pkg/fi/cloudup/azuretasks/disk.go b/upup/pkg/fi/cloudup/azuretasks/disk.go index 889cb3d0b70f4..a4c3442b5ecfa 100644 --- a/upup/pkg/fi/cloudup/azuretasks/disk.go +++ b/upup/pkg/fi/cloudup/azuretasks/disk.go @@ -35,7 +35,7 @@ type Disk struct { ResourceGroup *ResourceGroup SizeGB *int32 Tags map[string]*string - VolumeType *compute.DiskStorageAccountTypes + VolumeType *string Zones []*string } @@ -74,10 +74,13 @@ func (d *Disk) Find(c *fi.CloudupContext) (*Disk, error) { ResourceGroup: &ResourceGroup{ Name: d.ResourceGroup.Name, }, - SizeGB: found.Properties.DiskSizeGB, - Tags: found.Tags, - VolumeType: found.SKU.Name, - Zones: found.Zones, + SizeGB: found.Properties.DiskSizeGB, + Tags: found.Tags, + Zones: found.Zones, + } + if found.SKU != nil && found.SKU.Name != nil { + volumeType := string(*found.SKU.Name) + disk.VolumeType = &volumeType } if found.Properties != nil { disk.SizeGB = found.Properties.DiskSizeGB @@ -131,7 +134,7 @@ func (*Disk) RenderAzure(t *azure.AzureAPITarget, a, e, changes *Disk) error { DiskSizeGB: e.SizeGB, }, SKU: &compute.DiskSKU{ - Name: e.VolumeType, + Name: (*compute.DiskStorageAccountTypes)(e.VolumeType), }, Tags: e.Tags, Zones: e.Zones, diff --git a/upup/pkg/fi/cloudup/azuretasks/disk_test.go b/upup/pkg/fi/cloudup/azuretasks/disk_test.go index ec225245e9391..7044685ddcba3 100644 --- a/upup/pkg/fi/cloudup/azuretasks/disk_test.go +++ b/upup/pkg/fi/cloudup/azuretasks/disk_test.go @@ -29,8 +29,9 @@ import ( ) const ( - testTagKey = "key" - testTagValue = "value" + testTagKey = "key" + testTagValue = "value" + testVolumeType = "StandardSSD_LRS" ) func newTestDisk() *Disk { @@ -40,10 +41,8 @@ func newTestDisk() *Disk { ResourceGroup: &ResourceGroup{ Name: to.Ptr("rg"), }, - SizeGB: to.Ptr[int32](32), - VolumeType: &compute.DiskSKU{ - Name: to.Ptr(compute.DiskStorageAccountTypesStandardSSDLRS), - }, + SizeGB: to.Ptr[int32](32), + VolumeType: to.Ptr(testVolumeType), Tags: map[string]*string{ testTagKey: to.Ptr(testTagValue), },