diff --git a/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.stderr.golden b/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.stderr.golden index bbc15e3d0b..4e6d698440 100644 --- a/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.stderr.golden +++ b/cmd/scw/testdata/test-all-usage-instance-snapshot-create-usage.stderr.golden @@ -21,6 +21,7 @@ ARGS: FLAGS: -h, --help help for create + -w, --wait wait until the snapshot is ready GLOBAL FLAGS: -D, --debug Enable debug mode diff --git a/go.mod b/go.mod index b2d05da105..1c4c11939e 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/mattn/go-colorable v0.1.4 github.com/mattn/go-isatty v0.0.11 github.com/pkg/errors v0.9.1 // indirect - github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200428110639-7ec36ccf1cfc + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200430120055-da0e4c1879bc github.com/sergi/go-diff v1.0.0 // indirect github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index d349355b1e..5d69a3f006 100644 --- a/go.sum +++ b/go.sum @@ -62,6 +62,8 @@ github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200422170208-cd3e8b9e038c github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200422170208-cd3e8b9e038c/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200428110639-7ec36ccf1cfc h1:zJICGw5p88KTYAzdDFjyZRBENt3kIuDsM+e89gj+5q4= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200428110639-7ec36ccf1cfc/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200430120055-da0e4c1879bc h1:xwb3X3F2jWqN/vPvFOo/QDK4IcIEhmcs83CBV5bihtk= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200430120055-da0e4c1879bc/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= diff --git a/internal/namespaces/instance/v1/custom_snapshot.go b/internal/namespaces/instance/v1/custom_snapshot.go index 2bc7e6dc92..ff3f8bb69a 100644 --- a/internal/namespaces/instance/v1/custom_snapshot.go +++ b/internal/namespaces/instance/v1/custom_snapshot.go @@ -32,6 +32,16 @@ func snapshotCreateBuilder(c *core.Command) *core.Command { return runner(ctx, request) }) + + c.WaitFunc = func(ctx context.Context, argsI, respI interface{}) (interface{}, error) { + api := instance.NewAPI(core.ExtractClient(ctx)) + return api.WaitForSnapshot(&instance.WaitForSnapshotRequest{ + SnapshotID: respI.(*instance.CreateSnapshotResponse).Snapshot.ID, + Zone: argsI.(*customCreateSnapshotRequest).Zone, + Timeout: serverActionTimeout, + }) + } + return c }