diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-29 15:05:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-29 15:05:03 +0100 |
commit | 39c705e9405faa4d02b71165d05eec1e7bb44d93 (patch) | |
tree | f2b2ec4d93638ac661ab8f0c8c6aa38f234e8552 /pkg | |
parent | 7b99ef0b84c7b5e758544d0a25956674e7ea7db1 (diff) | |
parent | 79bf5010eda37c07f577414ae71ecb8f8c8714a2 (diff) | |
download | podman-39c705e9405faa4d02b71165d05eec1e7bb44d93.tar.gz podman-39c705e9405faa4d02b71165d05eec1e7bb44d93.tar.bz2 podman-39c705e9405faa4d02b71165d05eec1e7bb44d93.zip |
Merge pull request #4558 from rhatdan/reset
Add podman system reset command
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/reset.go | 13 | ||||
-rw-r--r-- | pkg/adapter/reset_remote.go | 12 | ||||
-rw-r--r-- | pkg/varlinkapi/system.go | 22 |
3 files changed, 46 insertions, 1 deletions
diff --git a/pkg/adapter/reset.go b/pkg/adapter/reset.go new file mode 100644 index 000000000..0decc3d15 --- /dev/null +++ b/pkg/adapter/reset.go @@ -0,0 +1,13 @@ +// +build !remoteclient + +package adapter + +import ( + "context" +) + +// Reset the container storage back to initial states. +// Removes all Pods, Containers, Images and Volumes. +func (r *LocalRuntime) Reset() error { + return r.Runtime.Reset(context.TODO()) +} diff --git a/pkg/adapter/reset_remote.go b/pkg/adapter/reset_remote.go new file mode 100644 index 000000000..663fab639 --- /dev/null +++ b/pkg/adapter/reset_remote.go @@ -0,0 +1,12 @@ +// +build remoteclient + +package adapter + +import ( + "github.com/containers/libpod/cmd/podman/varlink" +) + +// Info returns information for the host system and its components +func (r RemoteRuntime) Reset() error { + return iopodman.Reset().Call(r.Conn) +} diff --git a/pkg/varlinkapi/system.go b/pkg/varlinkapi/system.go index f6057f5fc..b81ff11ba 100644 --- a/pkg/varlinkapi/system.go +++ b/pkg/varlinkapi/system.go @@ -3,12 +3,15 @@ package varlinkapi import ( + "context" "fmt" - "github.com/containers/libpod/libpod/define" + "os" goruntime "runtime" "time" "github.com/containers/libpod/cmd/podman/varlink" + "github.com/containers/libpod/libpod/define" + "github.com/sirupsen/logrus" ) // GetVersion ... @@ -105,3 +108,20 @@ func (i *LibpodAPI) GetInfo(call iopodman.VarlinkCall) error { podmanInfo.Insecure_registries = insecureRegistries return call.ReplyGetInfo(podmanInfo) } + +// GetVersion ... +func (i *LibpodAPI) Reset(call iopodman.VarlinkCall) error { + if err := i.Runtime.Reset(context.TODO()); err != nil { + logrus.Errorf("Reset Failed: %v", err) + if err := call.ReplyErrorOccurred(err.Error()); err != nil { + logrus.Errorf("Failed to send ReplyErrorOccurred: %v", err) + } + os.Exit(define.ExecErrorCodeGeneric) + } + if err := call.ReplyReset(); err != nil { + logrus.Errorf("Failed to send ReplyReset: %v", err) + os.Exit(define.ExecErrorCodeGeneric) + } + os.Exit(0) + return nil +} |