Skip to content

Commit

Permalink
feat: Add 'expose_serial' attribute for image DS
Browse files Browse the repository at this point in the history
  • Loading branch information
adeatcu-ionos committed Jan 9, 2025
1 parent 0ab8f6d commit 5a0f846
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions docs/data-sources/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions ionoscloud/data_source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func dataSourceImage() *schema.Resource {
"location": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"version": {
Type: schema.TypeString,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ionoscloud/data_source_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand All @@ -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"),
),
},
{
Expand Down Expand Up @@ -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 + ` {
Expand Down

0 comments on commit 5a0f846

Please sign in to comment.