summaryrefslogtreecommitdiff
path: root/cmd/podman/system/prune.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2020-12-14 11:33:25 -0600
committerbaude <bbaude@redhat.com>2020-12-17 09:40:51 -0600
commit86335aa4ae01dadecd36468409d742e68b76925d (patch)
treefd6e5bfeb924db9020073685d0133b2fa38622c1 /cmd/podman/system/prune.go
parentc38ae47a1adf3235d8b01d724e7327e608dd8078 (diff)
downloadpodman-86335aa4ae01dadecd36468409d742e68b76925d.tar.gz
podman-86335aa4ae01dadecd36468409d742e68b76925d.tar.bz2
podman-86335aa4ae01dadecd36468409d742e68b76925d.zip
misc bindings to podman v3
manifest, system, info, volumes, play, and generate bindings are updated to always have binding options. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/system/prune.go')
-rw-r--r--cmd/podman/system/prune.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/cmd/podman/system/prune.go b/cmd/podman/system/prune.go
index 5ee017581..ea47e271f 100644
--- a/cmd/podman/system/prune.go
+++ b/cmd/podman/system/prune.go
@@ -4,6 +4,7 @@ import (
"bufio"
"context"
"fmt"
+ "net/url"
"os"
"strings"
@@ -12,12 +13,13 @@ import (
"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"
)
var (
- pruneOptions = entities.SystemPruneOptions{}
-
+ pruneOptions = entities.SystemPruneOptions{}
+ filters []string
pruneDescription = fmt.Sprintf(`
podman system prune
@@ -47,7 +49,7 @@ func init() {
flags.BoolVarP(&pruneOptions.All, "all", "a", false, "Remove all unused data")
flags.BoolVar(&pruneOptions.Volume, "volumes", false, "Prune volumes")
filterFlagName := "filter"
- flags.StringArrayVar(&pruneOptions.Filter, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
+ flags.StringArrayVar(&filters, filterFlagName, []string{}, "Provide filter values (e.g. 'label=<key>=<value>')")
_ = pruneCommand.RegisterFlagCompletionFunc(filterFlagName, completion.AutocompleteNone)
}
@@ -77,6 +79,15 @@ 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])
+ }
// TODO: support for filters in system prune
response, err := registry.ContainerEngine().SystemPrune(context.Background(), pruneOptions)
if err != nil {
@@ -100,7 +111,5 @@ Are you sure you want to continue? [y/N] `, volumeString)
}
}
// Print Images prune results
- utils.PrintImagePruneResults(response.ImagePruneReport, true)
-
- return nil
+ return utils.PrintImagePruneResults(response.ImagePruneReport, true)
}