Skip to content

Commit

Permalink
Merge pull request #9775 from jmguzik/system-prune-msg-fix
Browse files Browse the repository at this point in the history
Fix system prune cmd user message with options
  • Loading branch information
openshift-merge-robot authored Mar 22, 2021
2 parents 9ec936a + 1dfbdd5 commit 2cd37ed
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions cmd/podman/system/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
}

0 comments on commit 2cd37ed

Please sign in to comment.