Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instance): add wait flag on create snapshot #976

Merged
merged 2 commits into from
Apr 30, 2020
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 @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 10 additions & 0 deletions internal/namespaces/instance/v1/custom_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down