summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-22 11:02:19 -0500
committerGitHub <noreply@github.com>2020-12-22 11:02:19 -0500
commit07663f74c48d11732a3330248f837d5abf86fe9c (patch)
tree2446603ff11ddb7517fefee7c11fb5cf287fbbb7 /cmd
parentcfdb8fb29b34010206ea26f38e130d3e24403abf (diff)
parent5923656f321a9ca7b222c81cdb5f3387cc7cd3ad (diff)
downloadpodman-07663f74c48d11732a3330248f837d5abf86fe9c.tar.gz
podman-07663f74c48d11732a3330248f837d5abf86fe9c.tar.bz2
podman-07663f74c48d11732a3330248f837d5abf86fe9c.zip
Merge pull request #8724 from bblenard/support-volume-filters-in-system-prune
Add volume filters to system prune
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/system/prune.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go
index ea47e271f..a74363684 100644
--- a/cmd/podman/system/prune.go
+++ b/cmd/podman/system/prune.go
@@ -4,7 +4,6 @@ import (
"bufio"
"context"
"fmt"
- "net/url"
"os"
"strings"
@@ -12,8 +11,8 @@ 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"
+ lpfilters "github.com/containers/podman/v2/libpod/filters"
"github.com/containers/podman/v2/pkg/domain/entities"
- "github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -55,6 +54,8 @@ 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)
@@ -79,16 +80,11 @@ Are you sure you want to continue? [y/N] `, volumeString)
}
}
- pruneOptions.ContainerPruneOptions = entities.ContainerPruneOptions{}
- for _, f := range filters {
- t := strings.SplitN(f, "=", 2)
- pruneOptions.ContainerPruneOptions.Filters = make(url.Values)
- if len(t) < 2 {
- return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
- }
- pruneOptions.ContainerPruneOptions.Filters.Add(t[0], t[1])
+ pruneOptions.Filters, err = lpfilters.ParseFilterArgumentsIntoFilters(filters)
+ if err != nil {
+ return err
}
- // TODO: support for filters in system prune
+
response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions)
if err != nil {
return err