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 @@ -10,8 +10,9 @@ EXAMPLES:
scw apple-silicon server wait 11111111-1111-1111-1111-111111111111

ARGS:
server-id ID of the server.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
server-id ID of the server.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
[timeout=1h0m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
server-id ID of the server affected by the action.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
[timeout=20m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ EXAMPLES:
scw cockpit cockpit wait 11111111-1111-1111-1111-111111111111

ARGS:
project-id The ID of the project the cockpit is attached to
project-id The ID of the project the cockpit is attached to
[timeout=3m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ EXAMPLES:
scw instance image wait 11111111-1111-1111-1111-111111111111

ARGS:
image-id ID of the image.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
image-id ID of the image.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
[timeout=1h0m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EXAMPLES:
scw instance server wait 11111111-1111-1111-1111-111111111111

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ EXAMPLES:
scw instance snapshot wait 11111111-1111-1111-1111-111111111111

ARGS:
snapshot-id ID of the snapshot.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
snapshot-id ID of the snapshot.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config
[timeout=1h0m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ARGS:
cluster-id ID of the cluster.
[wait-for-pools] Wait for pools to be ready.
[region=fr-par] Region to target. If none is passed will use default region from the config
[timeout=10m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
node-id ID of the node.
[region=fr-par] Region to target. If none is passed will use default region from the config
[timeout=10m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
pool-id ID of the pool.
[region=fr-par] Region to target. If none is passed will use default region from the config
[timeout=10m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-lblb-wait-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
lb-id ID of the load balancer you want to wait for.
[zone=fr-par-1] Zone to target. If none is passed will use default zone from the config (fr-par-1 | fr-par-2 | pl-waw-1 | nl-ams-1)
[timeout=10m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
backup-id ID of the backup you want to wait for.
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
[timeout=20m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EXAMPLES:
ARGS:
instance-id ID of the instance you want to wait for.
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
[timeout=20m0s] Timeout of the wait

FLAGS:
-h, --help help for wait
Expand Down
1 change: 1 addition & 0 deletions docs/commands/apple-silicon.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ scw apple-silicon server wait <server-id ...> [arg=value ...]
|------|---|-------------|
| server-id | Required | ID of the server. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |
| timeout | Default: `1h0m0s` | Timeout of the wait |


**Examples:**
Expand Down
1 change: 1 addition & 0 deletions docs/commands/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ scw baremetal server wait <server-id ...> [arg=value ...]
|------|---|-------------|
| server-id | Required | ID of the server affected by the action. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |
| timeout | Default: `20m0s` | Timeout of the wait |


**Examples:**
Expand Down
1 change: 1 addition & 0 deletions docs/commands/cockpit.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ scw cockpit cockpit wait <project-id ...> [arg=value ...]
| Name | | Description |
|------|---|-------------|
| project-id | Required | The ID of the project the cockpit is attached to |
| timeout | Default: `3m0s` | Timeout of the wait |


**Examples:**
Expand Down
3 changes: 3 additions & 0 deletions docs/commands/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ scw instance image wait <image-id ...> [arg=value ...]
|------|---|-------------|
| image-id | Required | ID of the image. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |
| timeout | Default: `1h0m0s` | Timeout of the wait |


**Examples:**
Expand Down Expand Up @@ -2245,6 +2246,7 @@ scw instance server wait <server-id ...> [arg=value ...]

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

Expand Down Expand Up @@ -2572,6 +2574,7 @@ scw instance snapshot wait <snapshot-id ...> [arg=value ...]
|------|---|-------------|
| snapshot-id | Required | ID of the snapshot. |
| zone | Default: `fr-par-1` | Zone to target. If none is passed will use default zone from the config |
| timeout | Default: `1h0m0s` | Timeout of the wait |


**Examples:**
Expand Down
3 changes: 3 additions & 0 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ scw k8s cluster wait <cluster-id ...> [arg=value ...]
| cluster-id | Required | ID of the cluster. |
| wait-for-pools | | Wait for pools to be ready. |
| region | Default: `fr-par` | Region to target. If none is passed will use default region from the config |
| timeout | Default: `10m0s` | Timeout of the wait |


**Examples:**
Expand Down Expand Up @@ -753,6 +754,7 @@ scw k8s node wait <node-id ...> [arg=value ...]
|------|---|-------------|
| node-id | Required | ID of the node. |
| region | Default: `fr-par` | Region to target. If none is passed will use default region from the config |
| timeout | Default: `10m0s` | Timeout of the wait |


**Examples:**
Expand Down Expand Up @@ -1033,6 +1035,7 @@ scw k8s pool wait <pool-id ...> [arg=value ...]
|------|---|-------------|
| pool-id | Required | ID of the pool. |
| region | Default: `fr-par` | Region to target. If none is passed will use default region from the config |
| timeout | Default: `10m0s` | Timeout of the wait |


**Examples:**
Expand Down
1 change: 1 addition & 0 deletions docs/commands/lb.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ scw lb lb wait <lb-id ...> [arg=value ...]
|------|---|-------------|
| lb-id | Required | ID of the load balancer you want to wait for. |
| zone | Default: `fr-par-1`<br />One of: `fr-par-1`, `fr-par-2`, `pl-waw-1`, `nl-ams-1` | Zone to target. If none is passed will use default zone from the config |
| timeout | Default: `10m0s` | Timeout of the wait |


**Examples:**
Expand Down
2 changes: 2 additions & 0 deletions docs/commands/rdb.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ scw rdb backup wait <backup-id ...> [arg=value ...]
|------|---|-------------|
| backup-id | Required | ID of the backup you want to wait for. |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams` | Region to target. If none is passed will use default region from the config |
| timeout | Default: `20m0s` | Timeout of the wait |


**Examples:**
Expand Down Expand Up @@ -943,6 +944,7 @@ scw rdb instance wait <instance-id ...> [arg=value ...]
|------|---|-------------|
| instance-id | Required | ID of the instance you want to wait for. |
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams` | Region to target. If none is passed will use default region from the config |
| timeout | Default: `20m0s` | Timeout of the wait |


**Examples:**
Expand Down
9 changes: 9 additions & 0 deletions internal/core/arg_specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/scaleway/scaleway-sdk-go/validation"
Expand Down Expand Up @@ -214,3 +215,11 @@ func OrganizationIDArgSpec() *ArgSpec {
ValidateFunc: ValidateOrganizationID(),
}
}

func WaitTimeoutArgSpec(defaultTimeout time.Duration) *ArgSpec {
return &ArgSpec{
Name: "timeout",
Short: "Timeout of the wait",
Default: DefaultValueSetter(defaultTimeout.String()),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func serverWaitCommand() *core.Command {
cluster, err := api.WaitForServer(&applesilicon.WaitForServerRequest{
Zone: args.Zone,
ServerID: args.ServerID,
Timeout: scw.TimeDurationPtr(serverActionTimeout),
Timeout: args.Timeout,
RetryInterval: core.DefaultRetryInterval,
})
if err != nil {
Expand All @@ -115,6 +115,7 @@ func serverWaitCommand() *core.Command {
Positional: true,
},
core.ZoneArgSpec(),
core.WaitTimeoutArgSpec(serverActionTimeout),
},
Examples: []*core.Example{
{
Expand Down
16 changes: 10 additions & 6 deletions internal/namespaces/baremetal/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func serverWaitCommand() *core.Command {
type serverWaitRequest struct {
ServerID string
Zone scw.Zone
Timeout time.Duration
}

return &core.Command{
Expand All @@ -41,12 +42,14 @@ func serverWaitCommand() *core.Command {
Groups: []string{"workflow"},
ArgsType: reflect.TypeOf(serverWaitRequest{}),
Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) {
args := argsI.(*serverWaitRequest)

api := baremetal.NewAPI(core.ExtractClient(ctx))
logger.Debugf("starting to wait for server to reach a stable delivery status")
server, err := api.WaitForServer(&baremetal.WaitForServerRequest{
ServerID: argsI.(*serverWaitRequest).ServerID,
Zone: argsI.(*serverWaitRequest).Zone,
Timeout: scw.TimeDurationPtr(serverActionTimeout),
ServerID: args.ServerID,
Zone: args.Zone,
Timeout: scw.TimeDurationPtr(args.Timeout),
RetryInterval: core.DefaultRetryInterval,
})
if err != nil {
Expand All @@ -64,9 +67,9 @@ func serverWaitCommand() *core.Command {

logger.Debugf("server reached a stable delivery status. Will now starting to wait for server to reach a stable installation status")
server, err = api.WaitForServerInstall(&baremetal.WaitForServerInstallRequest{
ServerID: argsI.(*serverWaitRequest).ServerID,
Zone: argsI.(*serverWaitRequest).Zone,
Timeout: scw.TimeDurationPtr(serverActionTimeout),
ServerID: args.ServerID,
Zone: args.Zone,
Timeout: scw.TimeDurationPtr(args.Timeout),
RetryInterval: core.DefaultRetryInterval,
})
if err != nil {
Expand All @@ -89,6 +92,7 @@ func serverWaitCommand() *core.Command {
Positional: true,
},
core.ZoneArgSpec(),
core.WaitTimeoutArgSpec(serverActionTimeout),
},
Examples: []*core.Example{
{
Expand Down
8 changes: 6 additions & 2 deletions internal/namespaces/cockpit/v1beta1/custom_cockpit.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
func cockpitWaitCommand() *core.Command {
type cockpitWaitRequest struct {
ProjectID string
Timeout time.Duration
}

return &core.Command{
Expand All @@ -42,11 +43,13 @@ func cockpitWaitCommand() *core.Command {
Groups: []string{"workflow"},
ArgsType: reflect.TypeOf(cockpitWaitRequest{}),
Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) {
args := argsI.(*cockpitWaitRequest)

api := cockpit.NewAPI(core.ExtractClient(ctx))
logger.Debugf("starting to wait for cockpit to reach a stable delivery status")
targetCockpit, err := api.WaitForCockpit(&cockpit.WaitForCockpitRequest{
ProjectID: argsI.(*cockpitWaitRequest).ProjectID,
Timeout: scw.TimeDurationPtr(cockpitActionTimeout),
ProjectID: args.ProjectID,
Timeout: scw.TimeDurationPtr(args.Timeout),
RetryInterval: core.DefaultRetryInterval,
})
if err != nil {
Expand All @@ -69,6 +72,7 @@ func cockpitWaitCommand() *core.Command {
Required: true,
Positional: true,
},
core.WaitTimeoutArgSpec(cockpitActionTimeout),
},
Examples: []*core.Example{
{
Expand Down
3 changes: 2 additions & 1 deletion internal/namespaces/instance/v1/custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func imageWaitCommand() *core.Command {
return api.WaitForImage(&instance.WaitForImageRequest{
Zone: argsI.(*instance.WaitForImageRequest).Zone,
ImageID: argsI.(*instance.WaitForImageRequest).ImageID,
Timeout: scw.TimeDurationPtr(imageActionTimeout),
Timeout: argsI.(*instance.WaitForImageRequest).Timeout,
RetryInterval: core.DefaultRetryInterval,
})
},
Expand All @@ -460,6 +460,7 @@ func imageWaitCommand() *core.Command {
Positional: true,
},
core.ZoneArgSpec(),
core.WaitTimeoutArgSpec(imageActionTimeout),
},
Examples: []*core.Example{
{
Expand Down
28 changes: 25 additions & 3 deletions internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,12 @@ Once your image is ready you will be able to create a new server based on this i
}
}

type serverWaitRequest struct {
Zone scw.Zone
ServerID string
Timeout time.Duration
}

func serverWaitCommand() *core.Command {
return &core.Command{
Short: `Wait for server to reach a stable state`,
Expand All @@ -840,11 +846,27 @@ func serverWaitCommand() *core.Command {
Resource: "server",
Verb: "wait",
Groups: []string{"workflow"},
ArgsType: reflect.TypeOf(instanceActionRequest{}),
ArgsType: reflect.TypeOf(serverWaitRequest{}),
Run: func(ctx context.Context, argsI interface{}) (i interface{}, err error) {
return waitForServerFunc()(ctx, argsI, nil)
args := argsI.(*serverWaitRequest)

return instance.NewAPI(core.ExtractClient(ctx)).WaitForServer(&instance.WaitForServerRequest{
Zone: args.Zone,
ServerID: args.ServerID,
Timeout: scw.TimeDurationPtr(args.Timeout),
RetryInterval: core.DefaultRetryInterval,
})
},
ArgSpecs: core.ArgSpecs{
core.WaitTimeoutArgSpec(serverActionTimeout),
{
Name: "server-id",
Short: `ID of the server affected by the action.`,
Required: true,
Positional: true,
},
core.ZoneArgSpec(),
},
ArgSpecs: serverActionArgSpecs,
Examples: []*core.Example{
{
Short: "Wait for a server to reach a stable state",
Expand Down
3 changes: 2 additions & 1 deletion internal/namespaces/instance/v1/custom_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func snapshotWaitCommand() *core.Command {
return api.WaitForSnapshot(&instance.WaitForSnapshotRequest{
Zone: argsI.(*instance.WaitForSnapshotRequest).Zone,
SnapshotID: argsI.(*instance.WaitForSnapshotRequest).SnapshotID,
Timeout: scw.TimeDurationPtr(snapshotActionTimeout),
Timeout: argsI.(*instance.WaitForSnapshotRequest).Timeout,
RetryInterval: core.DefaultRetryInterval,
})
},
Expand All @@ -133,6 +133,7 @@ func snapshotWaitCommand() *core.Command {
Positional: true,
},
core.ZoneArgSpec(),
core.WaitTimeoutArgSpec(snapshotActionTimeout),
},
Examples: []*core.Example{
{
Expand Down
Loading