diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-10 13:32:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 13:32:41 -0500 |
commit | 6823a5d6cc771ed3c031518a759670dff7ee81b5 (patch) | |
tree | 29cf170f3139aca41dc7d2d182de729be1dec9d0 /pkg/domain | |
parent | 2bb149034bd67dd4027768863fed2fce853833ae (diff) | |
parent | 15cdcdca76f1cd21bd5f61edadec2fb7df307b1e (diff) | |
download | podman-6823a5d6cc771ed3c031518a759670dff7ee81b5.tar.gz podman-6823a5d6cc771ed3c031518a759670dff7ee81b5.tar.bz2 podman-6823a5d6cc771ed3c031518a759670dff7ee81b5.zip |
Merge pull request #8664 from rhatdan/prune
Add --filter to podman system prune
Diffstat (limited to 'pkg/domain')
-rw-r--r-- | pkg/domain/entities/system.go | 1 | ||||
-rw-r--r-- | pkg/domain/infra/abi/system.go | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/pkg/domain/entities/system.go b/pkg/domain/entities/system.go index bde2b6ef2..4af013134 100644 --- a/pkg/domain/entities/system.go +++ b/pkg/domain/entities/system.go @@ -19,6 +19,7 @@ type ServiceOptions struct { type SystemPruneOptions struct { All bool Volume bool + Filter []string } // SystemPruneReport provides report after system prune is executed. diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go index 7ed58092b..d6881fdc4 100644 --- a/pkg/domain/infra/abi/system.go +++ b/pkg/domain/infra/abi/system.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "io/ioutil" + "net/url" "os" "os/exec" "path/filepath" @@ -179,7 +180,16 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys found = true } systemPruneReport.PodPruneReport = append(systemPruneReport.PodPruneReport, podPruneReport...) - containerPruneReport, err := ic.pruneContainersHelper(nil) + containerPruneOptions := entities.ContainerPruneOptions{} + for _, f := range options.Filter { + t := strings.SplitN(f, "=", 2) + containerPruneOptions.Filters = make(url.Values) + if len(t) < 2 { + return nil, errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f) + } + containerPruneOptions.Filters.Add(t[0], t[1]) + } + containerPruneReport, err := ic.ContainerPrune(ctx, containerPruneOptions) if err != nil { return nil, err } @@ -194,7 +204,7 @@ func (ic *ContainerEngine) SystemPrune(ctx context.Context, options entities.Sys } } - results, err := ic.Libpod.ImageRuntime().PruneImages(ctx, options.All, nil) + results, err := ic.Libpod.ImageRuntime().PruneImages(ctx, options.All, options.Filter) if err != nil { return nil, err |