diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-28 18:11:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 18:11:39 +0200 |
commit | 4ed125f7b5228b3e5898e23fbb91d6db8b9a6c18 (patch) | |
tree | 03d2c90b648219f3481653f9cd7a84b78b2d4eba /pkg/bindings/system/system.go | |
parent | 5077aece7e7c7531f002116ffce33c0cf0d03ec3 (diff) | |
parent | 5436e314417e4822d105d1efdbea4e5442d6f42d (diff) | |
download | podman-4ed125f7b5228b3e5898e23fbb91d6db8b9a6c18.tar.gz podman-4ed125f7b5228b3e5898e23fbb91d6db8b9a6c18.tar.bz2 podman-4ed125f7b5228b3e5898e23fbb91d6db8b9a6c18.zip |
Merge pull request #5907 from sujil02/systemprune-v2
Adding system prune for podman v2
Diffstat (limited to 'pkg/bindings/system/system.go')
-rw-r--r-- | pkg/bindings/system/system.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go index e2f264139..df6b529de 100644 --- a/pkg/bindings/system/system.go +++ b/pkg/bindings/system/system.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "net/url" + "strconv" "github.com/containers/libpod/pkg/bindings" "github.com/containers/libpod/pkg/domain/entities" @@ -59,3 +60,26 @@ func Events(ctx context.Context, eventChan chan (entities.Event), cancelChan cha } return nil } + +// Prune removes all unused system data. +func Prune(ctx context.Context, all, volumes *bool) (*entities.SystemPruneReport, error) { + var ( + report entities.SystemPruneReport + ) + conn, err := bindings.GetClient(ctx) + if err != nil { + return nil, err + } + params := url.Values{} + if all != nil { + params.Set("All", strconv.FormatBool(*all)) + } + if volumes != nil { + params.Set("Volumes", strconv.FormatBool(*volumes)) + } + response, err := conn.DoRequest(nil, http.MethodPost, "/system/prune", params) + if err != nil { + return nil, err + } + return &report, response.Process(&report) +} |