|
5 | 5 | "errors"
|
6 | 6 | "fmt"
|
7 | 7 | "reflect"
|
| 8 | + "sort" |
8 | 9 | "strings"
|
9 | 10 |
|
10 | 11 | "github.com/scaleway/scaleway-cli/v2/core"
|
@@ -396,7 +397,9 @@ func serverTerminateCommand() *core.Command {
|
396 | 397 | _, _ = interactive.Printf("successfully detached volume %s\n", volumeName)
|
397 | 398 | }
|
398 | 399 | } else {
|
399 |
| - for _, volume := range server.Server.Volumes { |
| 400 | + successMessages := make(map[string]string) |
| 401 | + |
| 402 | + for index, volume := range server.Server.Volumes { |
400 | 403 | if volume.VolumeType != instance.VolumeServerVolumeTypeSbsVolume {
|
401 | 404 | continue
|
402 | 405 | }
|
@@ -428,8 +431,11 @@ func serverTerminateCommand() *core.Command {
|
428 | 431 | if err != nil {
|
429 | 432 | return nil, fmt.Errorf("failed to delete block volume %s: %w", blockVolume.Name, err)
|
430 | 433 | }
|
431 |
| - _, _ = interactive.Printf("successfully deleted block volume %q\n", blockVolume.Name) |
| 434 | + |
| 435 | + successMessages[index] = fmt.Sprintf("successfully deleted block volume %q", blockVolume.Name) |
432 | 436 | }
|
| 437 | + |
| 438 | + printSuccessMessagesInOrder(successMessages) |
433 | 439 | }
|
434 | 440 |
|
435 | 441 | if _, err := api.ServerAction(&instance.ServerActionRequest{
|
@@ -493,6 +499,19 @@ func shouldDeleteBlockVolumes(
|
493 | 499 | }
|
494 | 500 | }
|
495 | 501 |
|
| 502 | +// printSuccessMessagesInOrder prints volume deletion messages ordered by volume map key "0", "1", "2",... |
| 503 | +func printSuccessMessagesInOrder(messages map[string]string) { |
| 504 | + indexes := []string(nil) |
| 505 | + for index := range messages { |
| 506 | + indexes = append(indexes, index) |
| 507 | + } |
| 508 | + sort.Strings(indexes) |
| 509 | + |
| 510 | + for _, index := range indexes { |
| 511 | + _, _ = interactive.Println(messages[index]) |
| 512 | + } |
| 513 | +} |
| 514 | + |
496 | 515 | type instanceUniqueActionRequest struct {
|
497 | 516 | Zone scw.Zone
|
498 | 517 | ServerID string
|
|
0 commit comments