Skip to content

Commit 96be98d

Browse files
committed
Fix test
1 parent 323cffb commit 96be98d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

internal/services/k8s/pool.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"time"
77

8+
"github.com/hashicorp/go-cty/cty"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1011
"github.com/scaleway/scaleway-sdk-go/api/k8s/v1"
@@ -286,12 +287,18 @@ func ResourceK8SPoolCreate(ctx context.Context, d *schema.ResourceData, m any) d
286287
PublicIPDisabled: d.Get("public_ip_disabled").(bool),
287288
}
288289

289-
if v, ok := d.GetOk("region"); ok {
290-
req.Region = scw.Region(v.(string))
290+
rawConfig, diags := d.GetRawConfigAt(cty.GetAttrPath("region"))
291+
if diags == nil && rawConfig.IsKnown() && !rawConfig.IsNull() {
292+
if rawConfig.AsString() != "" {
293+
req.Region = scw.Region(rawConfig.AsString())
294+
}
291295
}
292296

293-
if v, ok := d.GetOk("zone"); ok {
294-
req.Zone = scw.Zone(v.(string))
297+
rawConfig, diags = d.GetRawConfigAt(cty.GetAttrPath("zone"))
298+
if diags == nil && rawConfig.IsKnown() && !rawConfig.IsNull() {
299+
if rawConfig.AsString() != "" {
300+
req.Zone = scw.Zone(rawConfig.AsString())
301+
}
295302
}
296303

297304
if placementGroupID, ok := d.GetOk("placement_group_id"); ok {

0 commit comments

Comments
 (0)