diff --git a/CHANGELOG.md b/CHANGELOG.md index e415f90c..ff68f766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,11 @@ -## 6.6.9 +## 6.6.9 -- upcoming release +### Features +- Add `expose_serial` attribute for image data source ### Docs - Replace < and > with " in the docs - Remove { and } from terraform imports - Replace \_ with _ in resource names + ## 6.6.8 ### Features - Add `auto_scaling` attribute to `ionoscloud_dataplatform_node_pool` resource. diff --git a/docs/data-sources/image.md b/docs/data-sources/image.md index e869f743..068a0bbc 100644 --- a/docs/data-sources/image.md +++ b/docs/data-sources/image.md @@ -75,6 +75,7 @@ The resulting string will be used to search for an exact match. An error will be * `disc_scsi_hot_unplug` - Is capable of SCSI drive hot unplug (no reboot required) * `licence_type` - OS type of this Image * `public` - Indicates if the image is part of the public repository or not + * `expose_serial` - Indicates if the serial ID of the disk attached to the server will be exposed or not. * `image_aliases` - List of image aliases mapped for this Image * `cloud_init` - Cloud init compatibility * `type` - This indicates the type of image diff --git a/ionoscloud/data_source_image.go b/ionoscloud/data_source_image.go index 030bf850..9e22b479 100644 --- a/ionoscloud/data_source_image.go +++ b/ionoscloud/data_source_image.go @@ -40,6 +40,7 @@ func dataSourceImage() *schema.Resource { "location": { Type: schema.TypeString, Optional: true, + Computed: true, }, "version": { Type: schema.TypeString, @@ -98,6 +99,10 @@ func dataSourceImage() *schema.Resource { Type: schema.TypeBool, Computed: true, }, + "expose_serial": { + Type: schema.TypeBool, + Computed: true, + }, "image_aliases": { Type: schema.TypeList, Computed: true, @@ -342,6 +347,12 @@ func ImageSetData(d *schema.ResourceData, image *ionoscloud.Image) error { } } + if image.Properties.ExposeSerial != nil { + if err := d.Set("expose_serial", *image.Properties.ExposeSerial); err != nil { + return err + } + } + if image.Properties.ImageAliases != nil && len(*image.Properties.ImageAliases) > 0 { if err := d.Set("image_aliases", *image.Properties.ImageAliases); err != nil { return err diff --git a/ionoscloud/data_source_image_test.go b/ionoscloud/data_source_image_test.go index 1950a708..798c9262 100644 --- a/ionoscloud/data_source_image_test.go +++ b/ionoscloud/data_source_image_test.go @@ -26,6 +26,7 @@ func TestAccDataSourceImageBasic(t *testing.T) { resource.TestCheckResourceAttr(imageTestName, "cloud_init", "V1"), resource.TestCheckResourceAttr(imageTestName, "location", "de/txl"), resource.TestCheckResourceAttr(imageTestName, "type", "HDD"), + resource.TestCheckResourceAttrSet(imageTestName, "expose_serial"), ), }, { @@ -43,6 +44,7 @@ func TestAccDataSourceImageBasic(t *testing.T) { resource.TestCheckResourceAttr(imageTestName, "location", "de/fkb"), resource.TestCheckResourceAttr(imageTestName, "name", "ubuntu-22.04-live-server-amd64.iso"), resource.TestCheckResourceAttr(imageTestName, "type", "CDROM"), + resource.TestCheckResourceAttrSet(imageTestName, "expose_serial"), ), }, { @@ -76,7 +78,7 @@ const testDataSourceImageAliasLocation = `data ` + constant.ImageResource + ` ` }` const testDataSourceImageAliasMultipleError = `data ` + constant.ImageResource + ` ` + constant.ImageTestResource + ` { - image_alias = "centos:latest" + image_alias = "ubuntu:22.04_iso" }` const testAccDataSourceWrongAliasError = `data ` + constant.ImageResource + ` ` + constant.ImageTestResource + ` {