Skip to content

Commit 8bdb428

Browse files
committed
update go.mod
1 parent a774dcf commit 8bdb428

File tree

8 files changed

+66
-84
lines changed

8 files changed

+66
-84
lines changed

docs/resources/instance_server.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ attached to the server. Updates to this field will trigger a stop/start of the s
255255
~> **Important:** If this field contains local volumes, you have to first detach them, in one apply, and then delete the volume in another apply.
256256

257257
- `filesystem` - (Optional) List of filesystems attached to the server.
258-
- `filesystem_id` - (Optional) The unique ID of the filesystem attached to the server.
258+
- `filesystem_id` - (Optional) The unique ID of the filesystem attached to the server.
259259

260260
- `enable_ipv6` - (Defaults to `false`) Determines if IPv6 is enabled for the server.
261261
Deprecated: Please use a scaleway_instance_ip with a `routed_ipv6` type.
@@ -319,7 +319,7 @@ In addition to all arguments above, the following attributes are exported:
319319
- `root_volume`
320320
- `volume_id` - The volume ID of the root volume of the server.
321321
- `filesystem`
322-
- `state` - The current status of the filesystem (e.g., attached, detached).
322+
- `state` - The current status of the filesystem (e.g., attached, detached).
323323
- `private_ip` - The Scaleway internal IP address of the server (Deprecated use [ipam_ip datasource](../data-sources/ipam_ip.md#instance-private-network-ip) instead).
324324
- `public_ip` - The public IP address of the server (Deprecated use `public_ips` instead).
325325
- `public_ips` - The list of public IPs of the server.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/nats-io/jwt/v2 v2.7.4
2929
github.com/nats-io/nats.go v1.38.0
3030
github.com/robfig/cron/v3 v3.0.1
31-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250610132304-0ea56270b666
31+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613151004-c065a4eb7430
3232
github.com/stretchr/testify v1.10.0
3333
golang.org/x/crypto v0.38.0
3434
gopkg.in/dnaeon/go-vcr.v3 v3.2.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
447447
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
448448
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
449449
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
450-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250610132304-0ea56270b666 h1:NYaPksM7wPC69Fe9VCUoYY8GYB1hplR6s5hO2PA9rSQ=
451-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250610132304-0ea56270b666/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g=
450+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613151004-c065a4eb7430 h1:npqerdt+HbDkv1+43FdhXNKnzKqkxfwgCCZDHgZRKNE=
451+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.33.0.20250613151004-c065a4eb7430/go.mod h1:zFWiHphneiey3s8HOtAEnGrRlWivNaxW5T6d5Xfco7g=
452452
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
453453
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
454454
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=

internal/services/file/filesystem_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,6 @@ func TestAccFileSystem_InvalidSizeGranularityFails(t *testing.T) {
106106
})
107107
}
108108

109-
func TestAccFileSystem_InvalidSizeGranularityFails(t *testing.T) {
110-
tt := acctest.NewTestTools(t)
111-
defer tt.Cleanup()
112-
113-
fileSystemName := "TestAccFileSystem_Basic"
114-
size := int64(25_000_000_000)
115-
116-
resource.ParallelTest(t, resource.TestCase{
117-
PreCheck: func() { acctest.PreCheck(t) },
118-
ProviderFactories: tt.ProviderFactories,
119-
CheckDestroy: filetestfuncs.CheckFileDestroy(tt),
120-
Steps: []resource.TestStep{
121-
{
122-
Config: fmt.Sprintf(`
123-
resource "scaleway_file_filesystem" "fs" {
124-
name = "%s"
125-
size = %d
126-
}
127-
`, fileSystemName, size),
128-
ExpectError: regexp.MustCompile("size does not respect constraint, size must be greater or equal to 100000000000"),
129-
},
130-
},
131-
})
132-
}
133-
134109
func testAccCheckFileSystemExists(tt *acctest.TestTools, n string) resource.TestCheckFunc {
135110
return func(s *terraform.State) error {
136111
rs, ok := s.RootModule().Resources[n]

internal/services/instance/helpers_instance.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/dustin/go-humanize"
1212
"github.com/hashicorp/terraform-plugin-log/tflog"
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1314
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1415
blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1"
1516
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
@@ -552,3 +553,46 @@ func getServerProjectID(ctx context.Context, api *instance.API, zone scw.Zone, s
552553

553554
return server.Server.Project, nil
554555
}
556+
557+
func attachNewFileSystem(newIDs map[string]struct{}, oldIDs map[string]struct{}, api *instancehelpers.BlockAndInstanceAPI, zone scw.Zone, server *instance.Server) (diag.Diagnostics, bool) {
558+
for id := range newIDs {
559+
if _, alreadyAttached := oldIDs[id]; !alreadyAttached {
560+
_, err := api.AttachServerFileSystem(&instance.AttachServerFileSystemRequest{
561+
Zone: zone,
562+
ServerID: server.ID,
563+
FilesystemID: locality.ExpandID(id),
564+
})
565+
if err != nil {
566+
return diag.FromErr(fmt.Errorf("error attaching filesystem %s: %w", id, err)), true
567+
}
568+
}
569+
}
570+
571+
return nil, false
572+
}
573+
574+
func detachOldFileSystem(oldIDs map[string]struct{}, newIDs map[string]struct{}, api *instancehelpers.BlockAndInstanceAPI, zone scw.Zone, server *instance.Server) (diag.Diagnostics, bool) {
575+
for id := range oldIDs {
576+
if _, stillPresent := newIDs[id]; !stillPresent {
577+
_, err := api.DetachServerFileSystem(&instance.DetachServerFileSystemRequest{
578+
Zone: zone,
579+
ServerID: server.ID,
580+
FilesystemID: locality.ExpandID(id),
581+
})
582+
if err != nil {
583+
return diag.FromErr(fmt.Errorf("error detaching filesystem %s: %w", id, err)), true
584+
}
585+
}
586+
}
587+
588+
return nil, false
589+
}
590+
591+
func collectFilesystemIDs(fsList []any, target map[string]struct{}) {
592+
for _, fs := range fsList {
593+
if fsMap, ok := fs.(map[string]any); ok {
594+
id := fsMap["filesystem_id"].(string)
595+
target[id] = struct{}{}
596+
}
597+
}
598+
}

internal/services/instance/server.go

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -539,17 +539,17 @@ func ResourceInstanceServerCreate(ctx context.Context, d *schema.ResourceData, m
539539
///
540540
// Attach Filesystem
541541
///
542-
_, err = waitForServer(ctx, api.API, zone, res.Server.ID, d.Timeout(schema.TimeoutCreate))
542+
543543
if filesystems, ok := d.GetOk("filesystems"); ok {
544-
for _, filesystem := range filesystems.([]interface{}) {
545-
fs := filesystem.(map[string]interface{})
544+
for _, filesystem := range filesystems.([]any) {
545+
fs := filesystem.(map[string]any)
546546
filesystemID := fs["filesystem_id"]
547+
547548
_, err := api.AttachServerFileSystem(&instanceSDK.AttachServerFileSystemRequest{
548549
Zone: zone,
549550
FilesystemID: regional.ExpandID(filesystemID.(string)).ID,
550551
ServerID: res.Server.ID,
551552
})
552-
553553
if err != nil {
554554
return nil
555555
}
@@ -1120,16 +1120,16 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
11201120
if d.HasChange("filesystems") {
11211121
oldRaw, newRaw := d.GetChange("filesystems")
11221122

1123-
oldList := oldRaw.([]interface{})
1124-
newList := newRaw.([]interface{})
1123+
oldList := oldRaw.([]any)
1124+
newList := newRaw.([]any)
11251125

11261126
oldIDs := make(map[string]struct{})
11271127
newIDs := make(map[string]struct{})
11281128

11291129
collectFilesystemIDs(oldList, oldIDs)
11301130
collectFilesystemIDs(newList, newIDs)
11311131

1132-
diagnostics, done := detachOlDFileSystem(oldIDs, newIDs, api, zone, server)
1132+
diagnostics, done := detachOldFileSystem(oldIDs, newIDs, api, zone, server)
11331133
if done {
11341134
return diagnostics
11351135
}
@@ -1239,47 +1239,6 @@ func ResourceInstanceServerUpdate(ctx context.Context, d *schema.ResourceData, m
12391239
return append(warnings, ResourceInstanceServerRead(ctx, d, m)...)
12401240
}
12411241

1242-
func attachNewFileSystem(newIDs map[string]struct{}, oldIDs map[string]struct{}, api *instancehelpers.BlockAndInstanceAPI, zone scw.Zone, server *instanceSDK.Server) (diag.Diagnostics, bool) {
1243-
for id := range newIDs {
1244-
if _, alreadyAttached := oldIDs[id]; !alreadyAttached {
1245-
_, err := api.AttachServerFileSystem(&instanceSDK.AttachServerFileSystemRequest{
1246-
Zone: zone,
1247-
ServerID: server.ID,
1248-
FilesystemID: locality.ExpandID(id),
1249-
})
1250-
if err != nil {
1251-
return diag.FromErr(fmt.Errorf("error attaching filesystem %s: %w", id, err)), true
1252-
}
1253-
}
1254-
}
1255-
return nil, false
1256-
}
1257-
1258-
func detachOlDFileSystem(oldIDs map[string]struct{}, newIDs map[string]struct{}, api *instancehelpers.BlockAndInstanceAPI, zone scw.Zone, server *instanceSDK.Server) (diag.Diagnostics, bool) {
1259-
for id := range oldIDs {
1260-
if _, stillPresent := newIDs[id]; !stillPresent {
1261-
_, err := api.DetachServerFileSystem(&instanceSDK.DetachServerFileSystemRequest{
1262-
Zone: zone,
1263-
ServerID: server.ID,
1264-
FilesystemID: locality.ExpandID(id),
1265-
})
1266-
if err != nil {
1267-
return diag.FromErr(fmt.Errorf("error detaching filesystem %s: %w", id, err)), true
1268-
}
1269-
}
1270-
}
1271-
return nil, false
1272-
}
1273-
1274-
func collectFilesystemIDs(fsList []interface{}, target map[string]struct{}) {
1275-
for _, fs := range fsList {
1276-
if fsMap, ok := fs.(map[string]interface{}); ok {
1277-
id := fsMap["filesystem_id"].(string)
1278-
target[id] = struct{}{}
1279-
}
1280-
}
1281-
}
1282-
12831242
func ResourceInstanceServerDelete(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
12841243
api, zone, id, err := instancehelpers.InstanceAndBlockAPIWithZoneAndID(m, d.Id())
12851244
if err != nil {
@@ -1319,14 +1278,17 @@ func ResourceInstanceServerDelete(ctx context.Context, d *schema.ResourceData, m
13191278

13201279
// Detach filesystem
13211280
if filesystems, ok := d.GetOk("filesystems"); ok {
1322-
fsList := filesystems.([]interface{})
1281+
fsList := filesystems.([]any)
13231282
for i, fsRaw := range fsList {
1324-
fsMap := fsRaw.(map[string]interface{})
1283+
fsMap := fsRaw.(map[string]any)
1284+
13251285
fsIDRaw, ok := fsMap["filesystem_id"]
13261286
if !ok || fsIDRaw == nil {
13271287
return diag.Errorf("filesystem_id is missing or nil for filesystem at index %d", i)
13281288
}
1289+
13291290
fsID := fsIDRaw.(string)
1291+
13301292
newFileSystemID := types.ExpandStringPtr(fsID)
13311293
if newFileSystemID == nil {
13321294
return diag.Errorf("failed to expand filesystem_id pointer at index %d", i)

internal/services/instance/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package instance
22

33
import (
4-
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
54
"strconv"
65

76
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
87
"github.com/scaleway/scaleway-sdk-go/scw"
8+
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/regional"
99
"github.com/scaleway/terraform-provider-scaleway/v2/internal/locality/zonal"
1010
)
1111

@@ -102,12 +102,12 @@ func flattenServerPublicIPs(zone scw.Zone, ips []*instance.ServerIP) []any {
102102
return flattenedIPs
103103
}
104104

105-
func flattenServerFileSystem(zone scw.Zone, fs []*instance.ServerFilesystem) []interface{} {
106-
filesystems := make([]interface{}, len(fs))
105+
func flattenServerFileSystem(zone scw.Zone, fs []*instance.ServerFilesystem) []any {
106+
filesystems := make([]any, len(fs))
107107
region, _ := zone.Region()
108108

109109
for i, f := range fs {
110-
filesystems[i] = map[string]interface{}{
110+
filesystems[i] = map[string]any{
111111
"filesystem_id": regional.NewIDString(region, f.FilesystemID),
112112
"status": f.State,
113113
}

internal/services/instance/waiters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func waitForFilesystems(ctx context.Context, api *instance.API, zone scw.Zone, i
9797
if transport.DefaultWaitRetryInterval != nil {
9898
retryInterval = *transport.DefaultWaitRetryInterval
9999
}
100+
100101
server, err := api.WaitForServerFileSystem(&instance.WaitForServerFileSystemRequest{
101102
ServerID: id,
102103
Zone: zone,

0 commit comments

Comments
 (0)