fix user message image prune --all
User message was the same as in the case of no flag provided.
This commit aligns message with the one used in docker.
[NO TESTS NEEDED]
@@ -53,9 +53,7 @@ func init() {
func prune(cmd *cobra.Command, args []string) error {
if !force {
reader := bufio.NewReader(os.Stdin)
- fmt.Printf(`
-WARNING! This will remove all dangling images.
-Are you sure you want to continue? [y/N] `)
+ fmt.Printf("%s", createPruneWarningMessage(pruneOpts))
answer, err := reader.ReadString('\n')
if err != nil {
return err
@@ -72,3 +70,11 @@ Are you sure you want to continue? [y/N] `)
return utils.PrintImagePruneResults(results, false)
}
+
+func createPruneWarningMessage(pruneOpts entities.ImagePruneOptions) string {
+ question := "Are you sure you want to continue? [y/N] "
+ if pruneOpts.All {
+ return "WARNING! This will remove all images without at least one container associated to them.\n" + question
+ }
+ return "WARNING! This will remove all dangling images.\n" + question
+}
