diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-22 09:57:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-22 09:57:26 -0700 |
commit | 2cd37edf02cca715df41ec915bbe0d6cfdc720e9 (patch) | |
tree | dc4769f6e69bdbe24f069ecfd66c4d3f622ea89a | |
parent | 9ec936a856a90eeb6a6300cc8bbdc7e7fbdcb9f4 (diff) | |
parent | 1dfbdd5d98ceb5e8a6d467a52c426a357465e28e (diff) | |
download | podman-2cd37edf02cca715df41ec915bbe0d6cfdc720e9.tar.gz podman-2cd37edf02cca715df41ec915bbe0d6cfdc720e9.tar.bz2 podman-2cd37edf02cca715df41ec915bbe0d6cfdc720e9.zip |
Merge pull request #9775 from jmguzik/system-prune-msg-fix
Fix system prune cmd user message with options
-rw-r--r-- | cmd/podman/system/prune.go | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go index 136c15304..3020a541b 100644 --- a/cmd/podman/system/prune.go +++ b/cmd/podman/system/prune.go @@ -55,22 +55,17 @@ func init() { func prune(cmd *cobra.Command, args []string) error { var err error - // Prompt for confirmation if --force is not set if !force { reader := bufio.NewReader(os.Stdin) volumeString := "" if pruneOptions.Volume { volumeString = ` - - all volumes not used by at least one container` + - all volumes not used by at least one container` } - fmt.Printf(` -WARNING! This will remove: - - all stopped containers%s - - all stopped pods - - all dangling images - - all build cache -Are you sure you want to continue? [y/N] `, volumeString) + + fmt.Printf(createPruneWarningMessage(pruneOptions), volumeString, "Are you sure you want to continue? [y/N] ") + answer, err := reader.ReadString('\n') if err != nil { return err @@ -115,3 +110,22 @@ Are you sure you want to continue? [y/N] `, volumeString) fmt.Printf("Total reclaimed space: %s\n", units.HumanSize((float64)(response.ReclaimedSpace))) return nil } + +func createPruneWarningMessage(pruneOpts entities.SystemPruneOptions) string { + if pruneOpts.All { + return `WARNING! This will remove: + - all stopped containers + - all networks not used by at least one container%s + - all images without at least one container associated to them + - all build cache + +%s` + } + return `WARNING! This will remove: + - all stopped containers + - all networks not used by at least one container%s + - all dangling images + - all dangling build cache + +%s` +} |