summaryrefslogtreecommitdiff
path: root/pkg/bindings/system
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-28 18:11:39 +0200
committerGitHub <noreply@github.com>2020-04-28 18:11:39 +0200
commit4ed125f7b5228b3e5898e23fbb91d6db8b9a6c18 (patch)
tree03d2c90b648219f3481653f9cd7a84b78b2d4eba /pkg/bindings/system
parent5077aece7e7c7531f002116ffce33c0cf0d03ec3 (diff)
parent5436e314417e4822d105d1efdbea4e5442d6f42d (diff)
downloadpodman-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')
-rw-r--r--pkg/bindings/system/system.go24
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)
+}