Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ AVAILABLE COMMANDS:
list List volumes
update Update a volume

WORKFLOW COMMANDS:
wait Wait for volume to reach a stable state

FLAGS:
-h, --help help for volume

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Wait for volume to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the volume.

USAGE:
scw instance volume wait <volume-id ...> [arg=value ...]

EXAMPLES:
Wait for a volume to reach a stable state
scw instance volume wait 11111111-1111-1111-1111-111111111111

ARGS:
[timeout=10m0s] Timeout of the wait
volume-id ID of the volume affected by the action.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config

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
32 changes: 32 additions & 0 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ it-generate-hosts-for-instance-servers,-baremetal,-apple-silicon-and-bastions)
- [Get a volume](#get-a-volume)
- [List volumes](#list-volumes)
- [Update a volume](#update-a-volume)
- [Wait for volume to reach a stable state](#wait-for-volume-to-reach-a-stable-state)
- [Volume type management commands](#volume-type-management-commands)
- [List volume types](#list-volume-types)

Expand Down Expand Up @@ -3091,6 +3092,37 @@ scw instance volume update 11111111-1111-1111-1111-111111111111 name=a-new-name



### Wait for volume to reach a stable state

Wait for volume to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the volume.

**Usage:**

```
scw instance volume wait <volume-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| timeout | Default: `10m0s` | Timeout of the wait |
| volume-id | Required | ID of the volume affected by the action. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |


**Examples:**


Wait for a volume to reach a stable state
```
scw instance volume wait 11111111-1111-1111-1111-111111111111
```




## Volume type management commands

All volume types available in a specified zone.
Expand Down
3 changes: 3 additions & 0 deletions internal/namespaces/instance/v1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func GetCommands() *core.Commands {

cmds.MustFind("instance", "volume", "create").Override(volumeCreateBuilder)
cmds.MustFind("instance", "volume", "list").Override(volumeListBuilder)
cmds.Merge(core.NewCommands(
volumeWaitCommand(),
))

//
// Volume-Type
Expand Down
46 changes: 46 additions & 0 deletions internal/namespaces/instance/v1/custom_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"context"
"fmt"
"reflect"
"time"

"github.com/fatih/color"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)

//
Expand Down Expand Up @@ -96,3 +98,47 @@ func volumeListBuilder(c *core.Command) *core.Command {
})
return c
}

type volumeWaitRequest struct {
Zone scw.Zone
VolumeID string
Timeout time.Duration
}

func volumeWaitCommand() *core.Command {
return &core.Command{
Short: `Wait for volume to reach a stable state`,
Long: `Wait for volume to reach a stable state. This is similar to using --wait flag on other action commands, but without requiring a new action on the volume.`,
Namespace: "instance",
Resource: "volume",
Verb: "wait",
Groups: []string{"workflow"},
ArgsType: reflect.TypeOf(volumeWaitRequest{}),
Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) {
args := argsI.(*volumeWaitRequest)

return instance.NewAPI(core.ExtractClient(ctx)).WaitForVolume(&instance.WaitForVolumeRequest{
Zone: args.Zone,
VolumeID: args.VolumeID,
Timeout: scw.TimeDurationPtr(args.Timeout),
RetryInterval: core.DefaultRetryInterval,
})
},
ArgSpecs: core.ArgSpecs{
core.WaitTimeoutArgSpec(serverActionTimeout),
{
Name: "volume-id",
Short: `ID of the volume affected by the action.`,
Required: true,
Positional: true,
},
core.ZoneArgSpec(),
},
Examples: []*core.Example{
{
Short: "Wait for a volume to reach a stable state",
ArgsJSON: `{"volume_id": "11111111-1111-1111-1111-111111111111"}`,
},
},
}
}