summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/prune.go5
-rw-r--r--cmd/podman/pods/prune.go5
-rw-r--r--cmd/podman/volumes/prune.go14
3 files changed, 11 insertions, 13 deletions
diff --git a/cmd/podman/containers/prune.go b/cmd/podman/containers/prune.go
index 90dea2b45..cfe6765ac 100644
--- a/cmd/podman/containers/prune.go
+++ b/cmd/podman/containers/prune.go
@@ -10,6 +10,7 @@ import (
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -25,6 +26,7 @@ var (
Long: pruneDescription,
RunE: prune,
Example: `podman container prune`,
+ Args: validate.NoArgs,
}
force bool
filter = []string{}
@@ -45,9 +47,6 @@ func prune(cmd *cobra.Command, args []string) error {
var (
pruneOptions = entities.ContainerPruneOptions{}
)
- if len(args) > 0 {
- return errors.Errorf("`%s` takes no arguments", cmd.CommandPath())
- }
if !force {
reader := bufio.NewReader(os.Stdin)
fmt.Println("WARNING! This will remove all non running containers.")
diff --git a/cmd/podman/pods/prune.go b/cmd/podman/pods/prune.go
index a7347ede5..f13d95ae9 100644
--- a/cmd/podman/pods/prune.go
+++ b/cmd/podman/pods/prune.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/utils"
+ "github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -23,6 +24,7 @@ var (
pruneCommand = &cobra.Command{
Use: "prune [flags]",
+ Args: validate.NoArgs,
Short: "Remove all stopped pods and their containers",
Long: pruneDescription,
RunE: prune,
@@ -41,9 +43,6 @@ func init() {
}
func prune(cmd *cobra.Command, args []string) error {
- if len(args) > 0 {
- return errors.Errorf("`%s` takes no arguments", cmd.CommandPath())
- }
if !pruneOptions.Force {
reader := bufio.NewReader(os.Stdin)
fmt.Println("WARNING! This will remove all stopped/exited pods..")
diff --git a/cmd/podman/volumes/prune.go b/cmd/podman/volumes/prune.go
index 95b47b726..78c258bec 100644
--- a/cmd/podman/volumes/prune.go
+++ b/cmd/podman/volumes/prune.go
@@ -29,10 +29,6 @@ var (
}
)
-var (
- pruneOptions entities.VolumePruneOptions
-)
-
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
@@ -40,12 +36,16 @@ func init() {
Parent: volumeCmd,
})
flags := pruneCommand.Flags()
- flags.BoolVarP(&pruneOptions.Force, "force", "f", false, "Do not prompt for confirmation")
+ flags.BoolP("force", "f", false, "Do not prompt for confirmation")
}
func prune(cmd *cobra.Command, args []string) error {
// Prompt for confirmation if --force is not set
- if !pruneOptions.Force {
+ force, err := cmd.Flags().GetBool("force")
+ if err != nil {
+ return err
+ }
+ if !force {
reader := bufio.NewReader(os.Stdin)
fmt.Println("WARNING! This will remove all volumes not used by at least one container.")
fmt.Print("Are you sure you want to continue? [y/N] ")
@@ -57,7 +57,7 @@ func prune(cmd *cobra.Command, args []string) error {
return nil
}
}
- responses, err := registry.ContainerEngine().VolumePrune(context.Background(), pruneOptions)
+ responses, err := registry.ContainerEngine().VolumePrune(context.Background())
if err != nil {
return err
}