From f419861e9b16d1577e0f9b2fdcd95568c44f1401 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Tue, 21 Jan 2025 17:27:33 +0100 Subject: [PATCH 1/7] feat(block): add snapshot wait command --- internal/namespaces/block/v1alpha1/custom.go | 4 + .../block/v1alpha1/custom_snapshot.go | 88 +++++++++++++++++++ .../block/v1alpha1/custom_snapshot_test.go | 48 ++++++++++ .../block/v1alpha1/custom_volume.go | 13 +++ .../block/v1alpha1/custom_volume_test.go | 40 +++++++++ .../namespaces/block/v1alpha1/helpers_test.go | 15 ++++ 6 files changed, 208 insertions(+) create mode 100644 internal/namespaces/block/v1alpha1/custom_snapshot.go create mode 100644 internal/namespaces/block/v1alpha1/custom_snapshot_test.go create mode 100644 internal/namespaces/block/v1alpha1/custom_volume_test.go create mode 100644 internal/namespaces/block/v1alpha1/helpers_test.go diff --git a/internal/namespaces/block/v1alpha1/custom.go b/internal/namespaces/block/v1alpha1/custom.go index 3a81298c39..8fbcbff142 100644 --- a/internal/namespaces/block/v1alpha1/custom.go +++ b/internal/namespaces/block/v1alpha1/custom.go @@ -46,6 +46,10 @@ func GetCommands() *core.Commands { cmds := GetGeneratedCommands() cmds.Add(volumeWaitCommand()) + cmds.Add(snapshotWaitCommand()) + + cmds.MustFind("block", "snapshot", "create").Override(blockSnapshotCreateBuilder) + cmds.MustFind("block", "volume", "create").Override(blockVolumeCreateBuilder) human.RegisterMarshalerFunc(block.VolumeStatus(""), human.EnumMarshalFunc(volumeStatusMarshalSpecs)) human.RegisterMarshalerFunc(block.SnapshotStatus(""), human.EnumMarshalFunc(snapshotStatusMarshalSpecs)) diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot.go b/internal/namespaces/block/v1alpha1/custom_snapshot.go new file mode 100644 index 0000000000..46bed3abc6 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/custom_snapshot.go @@ -0,0 +1,88 @@ +package block + +import ( + "context" + "reflect" + "time" + + "github.com/scaleway/scaleway-cli/v2/core" + block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" + "github.com/scaleway/scaleway-sdk-go/api/instance/v1" + "github.com/scaleway/scaleway-sdk-go/scw" +) + +const ( + snapshotActionTimeout = 5 * time.Minute +) + +type snapshotWaitRequest struct { + Zone scw.Zone + SnapshotID string + Timeout time.Duration + + TerminalStatus *block.SnapshotStatus +} + +func snapshotWaitCommand() *core.Command { + terminalStatus := block.SnapshotStatus("").Values() + terminalStatusStrings := make([]string, len(terminalStatus)) + for k, v := range terminalStatus { + terminalStatusStrings[k] = v.String() + } + + return &core.Command{ + Short: `Wait for snapshot to reach a stable state`, + Long: `Wait for snapshot to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the snapshot.`, + Namespace: "block", + Resource: "snapshot", + Verb: "wait", + Groups: []string{"workflow"}, + ArgsType: reflect.TypeOf(snapshotWaitRequest{}), + Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) { + args := argsI.(*snapshotWaitRequest) + + return block.NewAPI(core.ExtractClient(ctx)).WaitForSnapshot(&block.WaitForSnapshotRequest{ + Zone: args.Zone, + SnapshotID: args.SnapshotID, + Timeout: scw.TimeDurationPtr(args.Timeout), + RetryInterval: core.DefaultRetryInterval, + + TerminalStatus: args.TerminalStatus, + }) + }, + ArgSpecs: core.ArgSpecs{ + core.WaitTimeoutArgSpec(snapshotActionTimeout), + { + Name: "snapshot-id", + Short: `ID of the snapshot affected by the action.`, + Required: true, + Positional: true, + }, + { + Name: "terminal-status", + Short: `Expected terminal status, will wait until this status is reached.`, + EnumValues: terminalStatusStrings, + }, + core.ZoneArgSpec((*instance.API)(nil).Zones()...), + }, + Examples: []*core.Example{ + { + Short: "Wait for a snapshot to be available", + ArgsJSON: `{"snapshot_id": "11111111-1111-1111-1111-111111111111", "terminal_status": "available"}`, + }, + }, + } +} + +func blockSnapshotCreateBuilder(c *core.Command) *core.Command { + c.WaitFunc = func(ctx context.Context, argsI, respI interface{}) (interface{}, error) { + resp := respI.(*block.Snapshot) + + return block.NewAPI(core.ExtractClient(ctx)).WaitForSnapshot(&block.WaitForSnapshotRequest{ + SnapshotID: resp.ID, + Zone: resp.Zone, + }) + } + + return c +} diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot_test.go b/internal/namespaces/block/v1alpha1/custom_snapshot_test.go new file mode 100644 index 0000000000..30d5323bea --- /dev/null +++ b/internal/namespaces/block/v1alpha1/custom_snapshot_test.go @@ -0,0 +1,48 @@ +package block_test + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/v2/core" + block "github.com/scaleway/scaleway-cli/v2/internal/namespaces/block/v1alpha1" + "github.com/scaleway/scaleway-cli/v2/internal/testhelpers" + blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" + "github.com/stretchr/testify/require" +) + +func Test_SnapshotWait(t *testing.T) { + t.Run("Wait command", core.Test(&core.TestConfig{ + Commands: block.GetCommands(), + BeforeFunc: core.BeforeFuncCombine( + core.ExecStoreBeforeCmd("Volume", "scw block volume create perf-iops=5000 from-empty.size=20GB -w"), + core.ExecStoreBeforeCmd("Snapshot", "scw block snapshot create volume-id={{ .Volume.ID }}"), + ), + Cmd: "scw block snapshot wait {{ .Snapshot.ID }}", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + AfterFunc: core.AfterFuncCombine( + deleteSnapshot("Snapshot"), + deleteVolume("Volume"), + ), + })) + + t.Run("Wait flag", core.Test(&core.TestConfig{ + Commands: block.GetCommands(), + BeforeFunc: core.ExecStoreBeforeCmd("Volume", "scw block volume create perf-iops=5000 from-empty.size=20GB -w"), + Cmd: "scw block snapshot create volume-id={{ .Volume.ID }} -w", + Check: core.TestCheckCombine( + func(t *testing.T, ctx *core.CheckFuncCtx) { + snap := testhelpers.Value[*blockSDK.Snapshot](t, ctx.Result) + require.Equal(t, blockSDK.SnapshotStatusAvailable, snap.Status) + }, + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + AfterFunc: core.AfterFuncCombine( + deleteSnapshot("CmdResult"), + deleteVolume("Volume"), + ), + })) +} diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index 5885c139d0..ce4cafb251 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -73,3 +73,16 @@ func volumeWaitCommand() *core.Command { }, } } + +func blockVolumeCreateBuilder(c *core.Command) *core.Command { + c.WaitFunc = func(ctx context.Context, argsI, respI interface{}) (interface{}, error) { + resp := respI.(*block.Volume) + + return block.NewAPI(core.ExtractClient(ctx)).WaitForVolume(&block.WaitForVolumeRequest{ + VolumeID: resp.ID, + Zone: resp.Zone, + }) + } + + return c +} diff --git a/internal/namespaces/block/v1alpha1/custom_volume_test.go b/internal/namespaces/block/v1alpha1/custom_volume_test.go new file mode 100644 index 0000000000..741a4862ac --- /dev/null +++ b/internal/namespaces/block/v1alpha1/custom_volume_test.go @@ -0,0 +1,40 @@ +package block_test + +import ( + "testing" + + "github.com/scaleway/scaleway-cli/v2/core" + block "github.com/scaleway/scaleway-cli/v2/internal/namespaces/block/v1alpha1" + "github.com/scaleway/scaleway-cli/v2/internal/testhelpers" + blockSDK "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" + "github.com/stretchr/testify/require" +) + +func Test_VolumeWait(t *testing.T) { + t.Run("Wait command", core.Test(&core.TestConfig{ + Commands: block.GetCommands(), + BeforeFunc: core.BeforeFuncCombine( + core.ExecStoreBeforeCmd("Volume", "scw block volume create perf-iops=5000 from-empty.size=20GB"), + ), + Cmd: "scw block volume wait {{ .Volume.ID }}", + Check: core.TestCheckCombine( + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + AfterFunc: deleteVolume("Volume"), + })) + + t.Run("Wait flag", core.Test(&core.TestConfig{ + Commands: block.GetCommands(), + Cmd: "scw block volume create perf-iops=5000 from-empty.size=20GB -w", + Check: core.TestCheckCombine( + func(t *testing.T, ctx *core.CheckFuncCtx) { + vol := testhelpers.Value[*blockSDK.Volume](t, ctx.Result) + require.Equal(t, blockSDK.VolumeStatusAvailable, vol.Status) + }, + core.TestCheckGolden(), + core.TestCheckExitCode(0), + ), + AfterFunc: deleteVolume("CmdResult"), + })) +} diff --git a/internal/namespaces/block/v1alpha1/helpers_test.go b/internal/namespaces/block/v1alpha1/helpers_test.go new file mode 100644 index 0000000000..4eaf4f57c9 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/helpers_test.go @@ -0,0 +1,15 @@ +package block_test + +import "github.com/scaleway/scaleway-cli/v2/core" + +// deleteVolume deletes a volume. +// metaKey must be the key in meta where the volume state is stored. +func deleteVolume(metaKey string) core.AfterFunc { + return core.ExecAfterCmd("scw block volume delete {{." + metaKey + ".ID}}") +} + +// deleteSnapshot deletes a snapshot. +// metaKey must be the key in meta where the volume state is stored. +func deleteSnapshot(metaKey string) core.AfterFunc { + return core.ExecAfterCmd("scw block snapshot delete {{." + metaKey + ".ID}}") +} From aad96d091ddc1584ea3aa5af31675c1ba37a5f99 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Tue, 21 Jan 2025 17:28:20 +0100 Subject: [PATCH 2/7] add cassettes --- ...t-snapshot-wait-wait-command.cassette.yaml | 307 ++++++++++++++++++ .../test-snapshot-wait-wait-command.golden | 35 ++ ...test-snapshot-wait-wait-flag.cassette.yaml | 307 ++++++++++++++++++ .../test-snapshot-wait-wait-flag.golden | 35 ++ ...est-volume-wait-wait-command.cassette.yaml | 155 +++++++++ .../test-volume-wait-wait-command.golden | 33 ++ .../test-volume-wait-wait-flag.cassette.yaml | 155 +++++++++ .../test-volume-wait-wait-flag.golden | 33 ++ 8 files changed, 1060 insertions(+) create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.cassette.yaml create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.golden create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.cassette.yaml create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.golden create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.cassette.yaml create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.golden create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.cassette.yaml create mode 100644 internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.golden diff --git a/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.cassette.yaml b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.cassette.yaml new file mode 100644 index 0000000000..b804893824 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.cassette.yaml @@ -0,0 +1,307 @@ +--- +version: 1 +interactions: +- request: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes + method: POST + response: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "416" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:23 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f8502c25-8286-4c63-b38c-3d8b11a75057 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/6df15b31-60c4-40d7-8998-6eecae898290 + method: GET + response: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "416" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:23 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 294b1377-c02e-4e8e-9b92-d27d41ec185c + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/6df15b31-60c4-40d7-8998-6eecae898290 + method: GET + response: + body: '{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:23.642644Z", "updated_at":"2025-01-21T15:00:23.642644Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "417" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:28 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 06e4e04f-84b4-42ab-bb04-a901e2e21f0e + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots + method: POST + response: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "458" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:29 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - f4340efd-f33d-431d-b7c5-dce4455c739f + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/b1abe56e-aeec-4fc2-86d9-70899e742a9d + method: GET + response: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "458" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:29 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c7285e77-beae-4ae4-b55d-90c674f370f5 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"available", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/b1abe56e-aeec-4fc2-86d9-70899e742a9d + method: GET + response: + body: '{"id":"b1abe56e-aeec-4fc2-86d9-70899e742a9d", "name":"cli-snp-wizardly-blackwell", + "parent_volume":{"id":"6df15b31-60c4-40d7-8998-6eecae898290", "name":"cli-vol-lucid-fermi", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T15:00:28.960512Z", "updated_at":"2025-01-21T15:00:28.960512Z", + "references":[], "status":"available", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "459" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:34 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 014ad470-48e1-4b6d-9197-9a4d29cbd116 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/b1abe56e-aeec-4fc2-86d9-70899e742a9d + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:34 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 6bb0f90f-1d60-4410-a516-1042b3efa052 + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/6df15b31-60c4-40d7-8998-6eecae898290 + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 15:00:34 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge03) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 5f928d3a-bfff-4d38-ac65-bdc7066620ac + status: 204 No Content + code: 204 + duration: "" diff --git a/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.golden b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.golden new file mode 100644 index 0000000000..eaab6bd092 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-command.golden @@ -0,0 +1,35 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +ID b1abe56e-aeec-4fc2-86d9-70899e742a9d +Name cli-snp-wizardly-blackwell +ParentVolume.ID 6df15b31-60c4-40d7-8998-6eecae898290 +ParentVolume.Name cli-vol-lucid-fermi +ParentVolume.Type sbs_5k +ParentVolume.Status available +Size 20 GB +ProjectID ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b +CreatedAt few seconds ago +UpdatedAt few seconds ago +Status available +Zone fr-par-1 +Class sbs +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "id": "b1abe56e-aeec-4fc2-86d9-70899e742a9d", + "name": "cli-snp-wizardly-blackwell", + "parent_volume": { + "id": "6df15b31-60c4-40d7-8998-6eecae898290", + "name": "cli-vol-lucid-fermi", + "type": "sbs_5k", + "status": "available" + }, + "size": 20000000000, + "project_id": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at": "1970-01-01T00:00:00.0Z", + "updated_at": "1970-01-01T00:00:00.0Z", + "references": [], + "status": "available", + "tags": [], + "zone": "fr-par-1", + "class": "sbs" +} diff --git a/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.cassette.yaml b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.cassette.yaml new file mode 100644 index 0000000000..7e9c6a157b --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.cassette.yaml @@ -0,0 +1,307 @@ +--- +version: 1 +interactions: +- request: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes + method: POST + response: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "415" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:43 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - c71b3581-933e-4fe2-b2e5-fa54c0440bd6 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/dba8cdf8-4d13-4456-acdf-d0637d5a8f50 + method: GET + response: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "415" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:43 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - e1da0bbb-2e9e-4be2-8af5-21f18e47e27f + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/dba8cdf8-4d13-4456-acdf-d0637d5a8f50 + method: GET + response: + body: '{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:43.391757Z", "updated_at":"2025-01-21T14:58:43.391757Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "416" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 6169033a-9562-4d17-9c64-63d3504139cc + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots + method: POST + response: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "448" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - a2b21528-b573-46cb-aed9-b05b5c8afd52 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/c15492e2-fc63-4cc5-8b8f-de07eedfc1de + method: GET + response: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"creating", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "448" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:48 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 3b7271b2-06f7-4d3c-9cb5-1d55b519d0d0 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"available", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/c15492e2-fc63-4cc5-8b8f-de07eedfc1de + method: GET + response: + body: '{"id":"c15492e2-fc63-4cc5-8b8f-de07eedfc1de", "name":"cli-snp-serene-wu", + "parent_volume":{"id":"dba8cdf8-4d13-4456-acdf-d0637d5a8f50", "name":"cli-vol-bold-morse", + "type":"sbs_5k", "status":"available"}, "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:58:48.658546Z", "updated_at":"2025-01-21T14:58:48.658546Z", + "references":[], "status":"available", "tags":[], "class":"sbs", "zone":"fr-par-1"}' + headers: + Content-Length: + - "449" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:53 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 4c1b5442-ee6e-44d6-ada8-23dda1cb06b2 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/snapshots/c15492e2-fc63-4cc5-8b8f-de07eedfc1de + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:53 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - ab6e5731-5c9a-4585-9431-a449d9d12734 + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/dba8cdf8-4d13-4456-acdf-d0637d5a8f50 + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:58:54 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - b78646cd-1e3d-4c66-bf77-d76b93d68aba + status: 204 No Content + code: 204 + duration: "" diff --git a/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.golden b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.golden new file mode 100644 index 0000000000..a39c5c1234 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-snapshot-wait-wait-flag.golden @@ -0,0 +1,35 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +ID c15492e2-fc63-4cc5-8b8f-de07eedfc1de +Name cli-snp-serene-wu +ParentVolume.ID dba8cdf8-4d13-4456-acdf-d0637d5a8f50 +ParentVolume.Name cli-vol-bold-morse +ParentVolume.Type sbs_5k +ParentVolume.Status available +Size 20 GB +ProjectID ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b +CreatedAt few seconds ago +UpdatedAt few seconds ago +Status available +Zone fr-par-1 +Class sbs +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "id": "c15492e2-fc63-4cc5-8b8f-de07eedfc1de", + "name": "cli-snp-serene-wu", + "parent_volume": { + "id": "dba8cdf8-4d13-4456-acdf-d0637d5a8f50", + "name": "cli-vol-bold-morse", + "type": "sbs_5k", + "status": "available" + }, + "size": 20000000000, + "project_id": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at": "1970-01-01T00:00:00.0Z", + "updated_at": "1970-01-01T00:00:00.0Z", + "references": [], + "status": "available", + "tags": [], + "zone": "fr-par-1", + "class": "sbs" +} diff --git a/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.cassette.yaml b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.cassette.yaml new file mode 100644 index 0000000000..3a6d420861 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.cassette.yaml @@ -0,0 +1,155 @@ +--- +version: 1 +interactions: +- request: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes + method: POST + response: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "425" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:47:52 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 91b6a6d1-2f28-40bc-85bf-b153caf3b2ec + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/e09f17d5-7486-4750-b91a-3be27feab133 + method: GET + response: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "425" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:47:53 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 1d601dc8-f3f6-4677-b63e-f44549614dd6 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/e09f17d5-7486-4750-b91a-3be27feab133 + method: GET + response: + body: '{"id":"e09f17d5-7486-4750-b91a-3be27feab133", "name":"cli-vol-optimistic-northcutt", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:47:52.927439Z", "updated_at":"2025-01-21T14:47:52.927439Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "426" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:47:58 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 50c2710d-8625-41f9-be7f-77c4194253b3 + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/e09f17d5-7486-4750-b91a-3be27feab133 + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:47:58 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge02) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - d8ba37cd-cd77-4952-b664-00977ebce775 + status: 204 No Content + code: 204 + duration: "" diff --git a/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.golden b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.golden new file mode 100644 index 0000000000..d9b0945993 --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-command.golden @@ -0,0 +1,33 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +ID e09f17d5-7486-4750-b91a-3be27feab133 +Name cli-vol-optimistic-northcutt +Type sbs_5k +Size 20 GB +ProjectID ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b +CreatedAt few seconds ago +UpdatedAt few seconds ago +Status available +Zone fr-par-1 +Specs.PerfIops 5000 +Specs.Class sbs +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "id": "e09f17d5-7486-4750-b91a-3be27feab133", + "name": "cli-vol-optimistic-northcutt", + "type": "sbs_5k", + "size": 20000000000, + "project_id": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at": "1970-01-01T00:00:00.0Z", + "updated_at": "1970-01-01T00:00:00.0Z", + "references": [], + "parent_snapshot_id": null, + "status": "available", + "tags": [], + "zone": "fr-par-1", + "specs": { + "perf_iops": 5000, + "class": "sbs" + }, + "last_detached_at": null +} diff --git a/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.cassette.yaml b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.cassette.yaml new file mode 100644 index 0000000000..0dd416aaec --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.cassette.yaml @@ -0,0 +1,155 @@ +--- +version: 1 +interactions: +- request: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + Content-Type: + - application/json + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes + method: POST + response: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "422" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:56:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - e8c93980-32b1-471b-a172-e9e396485c41 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/105004b5-6b18-4f2a-957c-653d42391e00 + method: GET + response: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"creating", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "422" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:56:56 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 0736852f-9739-4533-b121-aa24b324f144 + status: 200 OK + code: 200 + duration: "" +- request: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/105004b5-6b18-4f2a-957c-653d42391e00 + method: GET + response: + body: '{"id":"105004b5-6b18-4f2a-957c-653d42391e00", "name":"cli-vol-practical-shirley", + "type":"sbs_5k", "size":20000000000, "project_id":"ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at":"2025-01-21T14:56:56.265134Z", "updated_at":"2025-01-21T14:56:56.265134Z", + "references":[], "parent_snapshot_id":null, "status":"available", "tags":[], + "specs":{"perf_iops":5000, "class":"sbs"}, "last_detached_at":null, "zone":"fr-par-1"}' + headers: + Content-Length: + - "423" + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:57:01 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 0c417069-8371-464d-9071-f3ddb493eafe + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + User-Agent: + - scaleway-sdk-go/v1.0.0-beta.7+dev (go1.23.4; darwin; arm64) cli-e2e-test + url: https://api.scaleway.com/block/v1alpha1/zones/fr-par-1/volumes/105004b5-6b18-4f2a-957c-653d42391e00 + method: DELETE + response: + body: "" + headers: + Content-Security-Policy: + - default-src 'none'; frame-ancestors 'none' + Content-Type: + - application/json + Date: + - Tue, 21 Jan 2025 14:57:01 GMT + Server: + - Scaleway API Gateway (fr-par-1;edge01) + Strict-Transport-Security: + - max-age=63072000 + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Request-Id: + - 208d5a61-e25b-4acc-8fd0-f012b54662bc + status: 204 No Content + code: 204 + duration: "" diff --git a/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.golden b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.golden new file mode 100644 index 0000000000..3bb04c962f --- /dev/null +++ b/internal/namespaces/block/v1alpha1/testdata/test-volume-wait-wait-flag.golden @@ -0,0 +1,33 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +🟩🟩🟩 STDOUT️ 🟩🟩🟩️ +ID 105004b5-6b18-4f2a-957c-653d42391e00 +Name cli-vol-practical-shirley +Type sbs_5k +Size 20 GB +ProjectID ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b +CreatedAt few seconds ago +UpdatedAt few seconds ago +Status available +Zone fr-par-1 +Specs.PerfIops 5000 +Specs.Class sbs +🟩🟩🟩 JSON STDOUT 🟩🟩🟩 +{ + "id": "105004b5-6b18-4f2a-957c-653d42391e00", + "name": "cli-vol-practical-shirley", + "type": "sbs_5k", + "size": 20000000000, + "project_id": "ee7bd9e1-9cbd-4724-b2f4-19e50f3cf38b", + "created_at": "1970-01-01T00:00:00.0Z", + "updated_at": "1970-01-01T00:00:00.0Z", + "references": [], + "parent_snapshot_id": null, + "status": "available", + "tags": [], + "zone": "fr-par-1", + "specs": { + "perf_iops": 5000, + "class": "sbs" + }, + "last_detached_at": null +} From e5ec71d2f074926e79c28f0da044f2b73c119740 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Tue, 21 Jan 2025 17:30:44 +0100 Subject: [PATCH 3/7] gen doc --- ...l-usage-block-snapshot-create-usage.golden | 1 + ...test-all-usage-block-snapshot-usage.golden | 3 ++ ...all-usage-block-snapshot-wait-usage.golden | 25 ++++++++++++++ ...all-usage-block-volume-create-usage.golden | 1 + docs/commands/block.md | 33 +++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 cmd/scw/testdata/test-all-usage-block-snapshot-wait-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-block-snapshot-create-usage.golden b/cmd/scw/testdata/test-all-usage-block-snapshot-create-usage.golden index 08388014ba..4760220693 100644 --- a/cmd/scw/testdata/test-all-usage-block-snapshot-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-block-snapshot-create-usage.golden @@ -15,6 +15,7 @@ ARGS: FLAGS: -h, --help help for create + -w, --wait wait until the snapshot is ready GLOBAL FLAGS: -c, --config string The path to the config file diff --git a/cmd/scw/testdata/test-all-usage-block-snapshot-usage.golden b/cmd/scw/testdata/test-all-usage-block-snapshot-usage.golden index 9cbfcb96d1..f9e1530a0e 100644 --- a/cmd/scw/testdata/test-all-usage-block-snapshot-usage.golden +++ b/cmd/scw/testdata/test-all-usage-block-snapshot-usage.golden @@ -14,6 +14,9 @@ AVAILABLE COMMANDS: list List all snapshots update Update a snapshot +WORKFLOW COMMANDS: + wait Wait for snapshot to reach a stable state + FLAGS: -h, --help help for snapshot diff --git a/cmd/scw/testdata/test-all-usage-block-snapshot-wait-usage.golden b/cmd/scw/testdata/test-all-usage-block-snapshot-wait-usage.golden new file mode 100644 index 0000000000..49cf4dbd49 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-block-snapshot-wait-usage.golden @@ -0,0 +1,25 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Wait for snapshot to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the snapshot. + +USAGE: + scw block snapshot wait [arg=value ...] + +EXAMPLES: + Wait for a snapshot to be available + scw block snapshot wait 11111111-1111-1111-1111-111111111111 terminal-status=available + +ARGS: + [timeout=5m0s] Timeout of the wait + snapshot-id ID of the snapshot affected by the action. + [terminal-status] Expected terminal status, will wait until this status is reached. (unknown_status | creating | available | error | deleting | deleted | in_use | locked | exporting) + [zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | fr-par-3 | nl-ams-1 | nl-ams-2 | nl-ams-3 | pl-waw-1 | pl-waw-2 | pl-waw-3) + +FLAGS: + -h, --help help for wait + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-block-volume-create-usage.golden b/cmd/scw/testdata/test-all-usage-block-volume-create-usage.golden index 8fb26fb33c..9a0b85793d 100644 --- a/cmd/scw/testdata/test-all-usage-block-volume-create-usage.golden +++ b/cmd/scw/testdata/test-all-usage-block-volume-create-usage.golden @@ -18,6 +18,7 @@ ARGS: FLAGS: -h, --help help for create + -w, --wait wait until the volume is ready GLOBAL FLAGS: -c, --config string The path to the config file diff --git a/docs/commands/block.md b/docs/commands/block.md index a0bbea2471..75590cc3a6 100644 --- a/docs/commands/block.md +++ b/docs/commands/block.md @@ -10,6 +10,7 @@ This API allows you to manage your Block Storage volumes. - [Import a snapshot from a Scaleway Object Storage bucket](#import-a-snapshot-from-a-scaleway-object-storage-bucket) - [List all snapshots](#list-all-snapshots) - [Update a snapshot](#update-a-snapshot) + - [Wait for snapshot to reach a stable state](#wait-for-snapshot-to-reach-a-stable-state) - [A Block Storage volume is a logical storage drive on a network-connected storage system. It is exposed to Instances as if it were a physical disk, and can be attached and detached like a hard drive. Several Block volumes can be attached to one Instance at a time](#a-block-storage-volume-is-a-logical-storage-drive-on-a-network-connected-storage-system.-it-is-exposed-to-instances-as-if-it-were-a-physical-disk,-and-can-be-attached-and-detached-like-a-hard-drive.-several-block-volumes-can-be-attached-to-one-instance-at-a-time) - [Create a volume](#create-a-volume) - [Delete a detached volume](#delete-a-detached-volume) @@ -185,6 +186,38 @@ scw block snapshot update [arg=value ...] +### Wait for snapshot to reach a stable state + +Wait for snapshot to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the snapshot. + +**Usage:** + +``` +scw block snapshot wait [arg=value ...] +``` + + +**Args:** + +| Name | | Description | +|------|---|-------------| +| timeout | Default: `5m0s` | Timeout of the wait | +| snapshot-id | Required | ID of the snapshot affected by the action. | +| terminal-status | One of: `unknown_status`, `creating`, `available`, `error`, `deleting`, `deleted`, `in_use`, `locked`, `exporting` | Expected terminal status, will wait until this status is reached. | +| zone | Default: `fr-par-1`
One of: `fr-par-1`, `fr-par-2`, `fr-par-3`, `nl-ams-1`, `nl-ams-2`, `nl-ams-3`, `pl-waw-1`, `pl-waw-2`, `pl-waw-3` | Zone to target. If none is passed will use default zone from the config | + + +**Examples:** + + +Wait for a snapshot to be available +``` +scw block snapshot wait 11111111-1111-1111-1111-111111111111 terminal-status=available +``` + + + + ## A Block Storage volume is a logical storage drive on a network-connected storage system. It is exposed to Instances as if it were a physical disk, and can be attached and detached like a hard drive. Several Block volumes can be attached to one Instance at a time Block volumes can be snapshotted, mounted or unmounted. From 1a98d19d23794ab4604e8212ff8e36a8ba84c81d Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Tue, 21 Jan 2025 17:45:59 +0100 Subject: [PATCH 4/7] lint --- internal/namespaces/block/v1alpha1/custom_snapshot.go | 2 +- internal/namespaces/block/v1alpha1/custom_snapshot_test.go | 1 + internal/namespaces/block/v1alpha1/custom_volume.go | 2 +- internal/namespaces/block/v1alpha1/custom_volume_test.go | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot.go b/internal/namespaces/block/v1alpha1/custom_snapshot.go index 46bed3abc6..6d5ce2bbff 100644 --- a/internal/namespaces/block/v1alpha1/custom_snapshot.go +++ b/internal/namespaces/block/v1alpha1/custom_snapshot.go @@ -75,7 +75,7 @@ func snapshotWaitCommand() *core.Command { } func blockSnapshotCreateBuilder(c *core.Command) *core.Command { - c.WaitFunc = func(ctx context.Context, argsI, respI interface{}) (interface{}, error) { + c.WaitFunc = func(ctx context.Context, _, respI interface{}) (interface{}, error) { resp := respI.(*block.Snapshot) return block.NewAPI(core.ExtractClient(ctx)).WaitForSnapshot(&block.WaitForSnapshotRequest{ diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot_test.go b/internal/namespaces/block/v1alpha1/custom_snapshot_test.go index 30d5323bea..4f54291360 100644 --- a/internal/namespaces/block/v1alpha1/custom_snapshot_test.go +++ b/internal/namespaces/block/v1alpha1/custom_snapshot_test.go @@ -34,6 +34,7 @@ func Test_SnapshotWait(t *testing.T) { Cmd: "scw block snapshot create volume-id={{ .Volume.ID }} -w", Check: core.TestCheckCombine( func(t *testing.T, ctx *core.CheckFuncCtx) { + t.Helper() snap := testhelpers.Value[*blockSDK.Snapshot](t, ctx.Result) require.Equal(t, blockSDK.SnapshotStatusAvailable, snap.Status) }, diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index ce4cafb251..22b62318bb 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -75,7 +75,7 @@ func volumeWaitCommand() *core.Command { } func blockVolumeCreateBuilder(c *core.Command) *core.Command { - c.WaitFunc = func(ctx context.Context, argsI, respI interface{}) (interface{}, error) { + c.WaitFunc = func(ctx context.Context, _, respI interface{}) (interface{}, error) { resp := respI.(*block.Volume) return block.NewAPI(core.ExtractClient(ctx)).WaitForVolume(&block.WaitForVolumeRequest{ diff --git a/internal/namespaces/block/v1alpha1/custom_volume_test.go b/internal/namespaces/block/v1alpha1/custom_volume_test.go index 741a4862ac..89f786a3d9 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume_test.go +++ b/internal/namespaces/block/v1alpha1/custom_volume_test.go @@ -29,6 +29,7 @@ func Test_VolumeWait(t *testing.T) { Cmd: "scw block volume create perf-iops=5000 from-empty.size=20GB -w", Check: core.TestCheckCombine( func(t *testing.T, ctx *core.CheckFuncCtx) { + t.Helper() vol := testhelpers.Value[*blockSDK.Volume](t, ctx.Result) require.Equal(t, blockSDK.VolumeStatusAvailable, vol.Status) }, From a5dcd0b29e8d0c384b388f56d137b582ce9904d7 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Wed, 22 Jan 2025 15:28:41 +0100 Subject: [PATCH 5/7] refactor: rename terminalStatus to statuses It represents a list of all statuses that can be used as terminal statuses if choosed by the user --- internal/namespaces/block/v1alpha1/custom_snapshot.go | 10 +++++----- internal/namespaces/block/v1alpha1/custom_volume.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/namespaces/block/v1alpha1/custom_snapshot.go b/internal/namespaces/block/v1alpha1/custom_snapshot.go index 6d5ce2bbff..8c2391f7a6 100644 --- a/internal/namespaces/block/v1alpha1/custom_snapshot.go +++ b/internal/namespaces/block/v1alpha1/custom_snapshot.go @@ -24,10 +24,10 @@ type snapshotWaitRequest struct { } func snapshotWaitCommand() *core.Command { - terminalStatus := block.SnapshotStatus("").Values() - terminalStatusStrings := make([]string, len(terminalStatus)) - for k, v := range terminalStatus { - terminalStatusStrings[k] = v.String() + snapshotsStatuses := block.SnapshotStatus("").Values() + snapshotsStatusStrings := make([]string, len(snapshotsStatuses)) + for k, v := range snapshotsStatuses { + snapshotsStatusStrings[k] = v.String() } return &core.Command{ @@ -61,7 +61,7 @@ func snapshotWaitCommand() *core.Command { { Name: "terminal-status", Short: `Expected terminal status, will wait until this status is reached.`, - EnumValues: terminalStatusStrings, + EnumValues: snapshotsStatusStrings, }, core.ZoneArgSpec((*instance.API)(nil).Zones()...), }, diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index 22b62318bb..429623cd18 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -24,10 +24,10 @@ type volumeWaitRequest struct { } func volumeWaitCommand() *core.Command { - terminalStatus := block.VolumeStatus("").Values() - terminalStatusStrings := make([]string, len(terminalStatus)) - for k, v := range terminalStatus { - terminalStatusStrings[k] = v.String() + volumeStatuses := block.VolumeStatus("").Values() + volumeStatusStrings := make([]string, len(volumeStatuses)) + for k, v := range volumeStatuses { + volumeStatusStrings[k] = v.String() } return &core.Command{ From 86cfcca2763768196738dfbaa5fbad59d6d751a3 Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Wed, 22 Jan 2025 15:30:30 +0100 Subject: [PATCH 6/7] fixup! refactor: rename terminalStatus to statuses It represents a list of all statuses that can be used as terminal statuses if choosed by the user typo --- internal/namespaces/block/v1alpha1/custom_volume.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index 429623cd18..eb61bcd310 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -61,8 +61,8 @@ func volumeWaitCommand() *core.Command { { Name: "terminal-status", Short: `Expected terminal status, will wait until this status is reached.`, - EnumValues: terminalStatusStrings, - }, + EnumValues: volumeStatusStrings, + }, g core.ZoneArgSpec((*instance.API)(nil).Zones()...), }, Examples: []*core.Example{ From 4ffdea55eb6a3ee68f4c44b11422363aa5459f5c Mon Sep 17 00:00:00 2001 From: Jules Casteran Date: Wed, 22 Jan 2025 15:32:06 +0100 Subject: [PATCH 7/7] fixup! fixup! refactor: rename terminalStatus to statuses It represents a list of all statuses that can be used as terminal statuses if choosed by the user remove extra character --- internal/namespaces/block/v1alpha1/custom_volume.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/namespaces/block/v1alpha1/custom_volume.go b/internal/namespaces/block/v1alpha1/custom_volume.go index eb61bcd310..c032687dcc 100644 --- a/internal/namespaces/block/v1alpha1/custom_volume.go +++ b/internal/namespaces/block/v1alpha1/custom_volume.go @@ -62,7 +62,7 @@ func volumeWaitCommand() *core.Command { Name: "terminal-status", Short: `Expected terminal status, will wait until this status is reached.`, EnumValues: volumeStatusStrings, - }, g + }, core.ZoneArgSpec((*instance.API)(nil).Zones()...), }, Examples: []*core.Example{