From 19febda3032d2d8cdb9131a9f318c0079b8218da Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Thu, 15 Oct 2020 17:35:33 +0200 Subject: [PATCH 1/4] Adding support for os_disk_image_size to get the disk size of the image --- .../compute/shared_image_version_data_source.go | 11 +++++++++++ website/docs/d/shared_image_version.html.markdown | 2 ++ 2 files changed, 13 insertions(+) diff --git a/azurerm/internal/services/compute/shared_image_version_data_source.go b/azurerm/internal/services/compute/shared_image_version_data_source.go index 951085a0a555..9409d684ba56 100644 --- a/azurerm/internal/services/compute/shared_image_version_data_source.go +++ b/azurerm/internal/services/compute/shared_image_version_data_source.go @@ -56,6 +56,11 @@ func dataSourceArmSharedImageVersion() *schema.Resource { Computed: true, }, + "os_disk_image_size": { + Type: schema.TypeInt, + Computed: true, + }, + "target_region": { Type: schema.TypeList, Computed: true, @@ -133,6 +138,12 @@ func dataSourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{ osDiskSnapShotID = *profile.OsDiskImage.Source.ID } d.Set("os_disk_snapshot_id", osDiskSnapShotID) + + osDiskImageSize := -1 + if profile.OsDiskImage != nil && profile.OsDiskImage.SizeInGB != nil { + osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) + } + d.Set("os_disk_image_size", osDiskImageSize) } } diff --git a/website/docs/d/shared_image_version.html.markdown b/website/docs/d/shared_image_version.html.markdown index 375c2b437e4c..b5c6920ebd24 100644 --- a/website/docs/d/shared_image_version.html.markdown +++ b/website/docs/d/shared_image_version.html.markdown @@ -52,6 +52,8 @@ The following attributes are exported: * `os_disk_snapshot_id` - The ID of the OS disk snapshot which was the source of this Shared Image Version. +* `os_disk_image_size` - The size of the OS disk snapshot which was the source of this Shared Image Version. + * `tags` - A mapping of tags assigned to the Shared Image. --- From 177cdeabea98c222938fa2d6b645c051a9f36e78 Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Thu, 15 Oct 2020 18:36:16 +0200 Subject: [PATCH 2/4] Fixing the formatting... --- .../services/compute/shared_image_version_data_source.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/compute/shared_image_version_data_source.go b/azurerm/internal/services/compute/shared_image_version_data_source.go index 9409d684ba56..7891104ccd43 100644 --- a/azurerm/internal/services/compute/shared_image_version_data_source.go +++ b/azurerm/internal/services/compute/shared_image_version_data_source.go @@ -141,7 +141,7 @@ func dataSourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{ osDiskImageSize := -1 if profile.OsDiskImage != nil && profile.OsDiskImage.SizeInGB != nil { - osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) + osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) } d.Set("os_disk_image_size", osDiskImageSize) } From 042c2e1cd0bfc7b93555102a833d42fdb97f7c69 Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Thu, 15 Oct 2020 19:04:13 +0200 Subject: [PATCH 3/4] Fixing the formatting with make fmt now --- .../services/compute/shared_image_version_data_source.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/compute/shared_image_version_data_source.go b/azurerm/internal/services/compute/shared_image_version_data_source.go index 7891104ccd43..1bb647cbfd46 100644 --- a/azurerm/internal/services/compute/shared_image_version_data_source.go +++ b/azurerm/internal/services/compute/shared_image_version_data_source.go @@ -141,8 +141,8 @@ func dataSourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{ osDiskImageSize := -1 if profile.OsDiskImage != nil && profile.OsDiskImage.SizeInGB != nil { - osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) - } + osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) + } d.Set("os_disk_image_size", osDiskImageSize) } } From 74c80aa1cbea56ac04e977701d016a6d96d4fd9a Mon Sep 17 00:00:00 2001 From: Harshavardhan Musanalli Date: Mon, 19 Oct 2020 09:28:58 +0200 Subject: [PATCH 4/4] replacing os_disk_image_size with os_disk_image_size_gb as per Hashicorp's suggestion... Defaulting osDiskImageSize to 0 --- .../services/compute/shared_image_version_data_source.go | 6 +++--- website/docs/d/shared_image_version.html.markdown | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/compute/shared_image_version_data_source.go b/azurerm/internal/services/compute/shared_image_version_data_source.go index 1bb647cbfd46..9e860854fd19 100644 --- a/azurerm/internal/services/compute/shared_image_version_data_source.go +++ b/azurerm/internal/services/compute/shared_image_version_data_source.go @@ -56,7 +56,7 @@ func dataSourceArmSharedImageVersion() *schema.Resource { Computed: true, }, - "os_disk_image_size": { + "os_disk_image_size_gb": { Type: schema.TypeInt, Computed: true, }, @@ -139,11 +139,11 @@ func dataSourceArmSharedImageVersionRead(d *schema.ResourceData, meta interface{ } d.Set("os_disk_snapshot_id", osDiskSnapShotID) - osDiskImageSize := -1 + osDiskImageSize := 0 if profile.OsDiskImage != nil && profile.OsDiskImage.SizeInGB != nil { osDiskImageSize = int(*profile.OsDiskImage.SizeInGB) } - d.Set("os_disk_image_size", osDiskImageSize) + d.Set("os_disk_image_size_gb", osDiskImageSize) } } diff --git a/website/docs/d/shared_image_version.html.markdown b/website/docs/d/shared_image_version.html.markdown index b5c6920ebd24..bd5c1b9ac13d 100644 --- a/website/docs/d/shared_image_version.html.markdown +++ b/website/docs/d/shared_image_version.html.markdown @@ -52,7 +52,7 @@ The following attributes are exported: * `os_disk_snapshot_id` - The ID of the OS disk snapshot which was the source of this Shared Image Version. -* `os_disk_image_size` - The size of the OS disk snapshot which was the source of this Shared Image Version. +* `os_disk_image_size_gb` - The size of the OS disk snapshot (in Gigabytes) which was the source of this Shared Image Version. * `tags` - A mapping of tags assigned to the Shared Image.