Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit d2a6082

Browse files
author
Alexandr Sokolov
committed
data_source gcore_image could load baremetal images
1 parent 28ca0ed commit d2a6082

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

docs/data-sources/gcore_image.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ output "view" {
4949
### Optional
5050

5151
- **id** (String) The ID of this resource.
52+
- **is_baremetal** (Boolean) set to true if need to get baremetal image
5253
- **project_id** (Number)
5354
- **project_name** (String)
5455
- **region_id** (Number)

gcore/data_source_gcore_image.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
)
1212

1313
const (
14-
imagesPoint = "images"
14+
imagesPoint = "images"
15+
bmImagesPoint = "bmimages"
1516
)
1617

1718
func dataSourceImage() *schema.Resource {
@@ -56,6 +57,11 @@ func dataSourceImage() *schema.Resource {
5657
Description: "use 'os-version', for example 'ubuntu-20.04'",
5758
Required: true,
5859
},
60+
"is_baremetal": &schema.Schema{
61+
Type: schema.TypeBool,
62+
Description: "set to true if need to get baremetal image",
63+
Optional: true,
64+
},
5965
"min_disk": &schema.Schema{
6066
Type: schema.TypeInt,
6167
Computed: true,
@@ -76,11 +82,6 @@ func dataSourceImage() *schema.Resource {
7682
Type: schema.TypeString,
7783
Computed: true,
7884
},
79-
//todo: uncomment after patching gcorelabscloud-go
80-
//"is_baremetal": &schema.Schema{
81-
// Type: schema.TypeString,
82-
// Required: true,
83-
//},
8485
},
8586
}
8687
}
@@ -92,7 +93,11 @@ func dataSourceImageRead(ctx context.Context, d *schema.ResourceData, m interfac
9293
config := m.(*Config)
9394
provider := config.Provider
9495

95-
client, err := CreateClient(provider, d, imagesPoint, versionPointV1)
96+
point := imagesPoint
97+
if isBm, _ := d.Get("is_baremetal").(bool); isBm {
98+
point = bmImagesPoint
99+
}
100+
client, err := CreateClient(provider, d, point, versionPointV1)
96101
if err != nil {
97102
return diag.FromErr(err)
98103
}

0 commit comments

Comments
 (0)