diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/images/build.go | 3 | ||||
-rw-r--r-- | cmd/podman/system/prune.go | 18 |
2 files changed, 9 insertions, 12 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index fbea1e3d8..3aca104e3 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -221,7 +221,8 @@ func build(cmd *cobra.Command, args []string) error { var logfile *os.File if cmd.Flag("logfile").Changed { - logfile, err := os.OpenFile(buildOpts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) + var err error + logfile, err = os.OpenFile(buildOpts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) if err != nil { return err } 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 |