9
9
"github.com/scaleway/scaleway-sdk-go/scw"
10
10
"github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource"
11
11
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
12
+ "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify"
12
13
)
13
14
14
15
func DataSourceImage () * schema.Resource {
@@ -26,6 +27,13 @@ func DataSourceImage() *schema.Resource {
26
27
Default : "DEV1-S" ,
27
28
Description : "The instance commercial type of the desired image" ,
28
29
},
30
+ "image_type" : {
31
+ Type : schema .TypeString ,
32
+ Optional : true ,
33
+ Default : "instance_local" , // Keep the old default as default to avoid a breaking change.
34
+ Description : "The type of the desired image, instance_local or instance_sbs" ,
35
+ ValidateDiagFunc : verify .ValidateEnum [marketplace.LocalImageType ](),
36
+ },
29
37
"zone" : zonal .Schema (),
30
38
},
31
39
}
@@ -41,7 +49,7 @@ func DataSourceMarketplaceImageRead(ctx context.Context, d *schema.ResourceData,
41
49
ImageLabel : d .Get ("label" ).(string ),
42
50
CommercialType : d .Get ("instance_type" ).(string ),
43
51
Zone : zone ,
44
- Type : marketplace .LocalImageTypeInstanceLocal ,
52
+ Type : marketplace .LocalImageType ( d . Get ( "image_type" ).( string )) ,
45
53
}, scw .WithContext (ctx ))
46
54
if err != nil {
47
55
return diag .FromErr (err )
@@ -52,6 +60,7 @@ func DataSourceMarketplaceImageRead(ctx context.Context, d *schema.ResourceData,
52
60
_ = d .Set ("zone" , zone )
53
61
_ = d .Set ("label" , d .Get ("label" ))
54
62
_ = d .Set ("instance_type" , d .Get ("type" ))
63
+ _ = d .Set ("image_type" , image .Type )
55
64
56
65
return nil
57
66
}
0 commit comments