@@ -14,6 +14,11 @@ type WaitForSnapshotRequest struct {
1414 Zone scw.Zone
1515 Timeout * time.Duration
1616 RetryInterval * time.Duration
17+
18+ // If set, will wait until this specific status has been reached or the
19+ // snapshot has an error status. This is useful when we need to wait for
20+ // the snapshot to transition from "in_use" to "available".
21+ TerminalStatus * SnapshotStatus
1722}
1823
1924// WaitForSnapshot wait for the snapshot to be in a "terminal state" before returning.
@@ -28,11 +33,16 @@ func (s *API) WaitForSnapshot(req *WaitForSnapshotRequest, opts ...scw.RequestOp
2833 }
2934
3035 terminalStatus := map [SnapshotStatus ]struct {}{
31- SnapshotStatusAvailable : {},
32- SnapshotStatusInUse : {},
33- SnapshotStatusError : {},
34- SnapshotStatusLocked : {},
35- SnapshotStatusDeleted : {},
36+ SnapshotStatusError : {},
37+ SnapshotStatusLocked : {},
38+ SnapshotStatusDeleted : {},
39+ }
40+
41+ if req .TerminalStatus != nil {
42+ terminalStatus [* req .TerminalStatus ] = struct {}{}
43+ } else {
44+ terminalStatus [SnapshotStatusAvailable ] = struct {}{}
45+ terminalStatus [SnapshotStatusInUse ] = struct {}{}
3646 }
3747
3848 snapshot , err := async .WaitSync (& async.WaitSyncConfig {
0 commit comments