Skip to content

Commit 6a03f32

Browse files
committed
Added confirmation when removing volumes #1437
Signed-off-by: Corentin Grall <corentin.grall@gmail.com>
1 parent 727a83b commit 6a03f32

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cli/command/volume/remove.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"strings"
7+
"os"
78

89
"github.com/docker/cli/cli"
910
"github.com/docker/cli/cli/command"
@@ -45,12 +46,21 @@ func runRemove(dockerCli command.Cli, opts *removeOptions) error {
4546

4647
var errs []string
4748

49+
50+
4851
for _, name := range opts.volumes {
52+
53+
deleteRemote := command.PromptForConfirmation(os.Stdin, dockerCli.Out(), fmt.Sprintf("\nPlease confirm you would like to remove volume %s ?", name))
54+
if !deleteRemote {
55+
fmt.Fprintf(dockerCli.Out(), "Volume %s wasn't deleted.\n", name)
56+
continue
57+
}
58+
4959
if err := client.VolumeRemove(ctx, name, opts.force); err != nil {
5060
errs = append(errs, err.Error())
5161
continue
5262
}
53-
fmt.Fprintf(dockerCli.Out(), "%s\n", name)
63+
fmt.Fprintf(dockerCli.Out(), "Sucessfully deleted volume %s\n", name)
5464
}
5565

5666
if len(errs) > 0 {

0 commit comments

Comments
 (0)