summaryrefslogtreecommitdiff
path: root/cmd/kpod/pause.go
diff options
context:
space:
mode:
authorumohnani8 <umohnani@redhat.com>2017-11-22 15:36:00 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-24 15:53:17 +0000
commitb1a3b030688e28e6d7473d998cabbf923a8064f9 (patch)
tree7f6bdd607a3472def8601f36cbde64e52aa3065b /cmd/kpod/pause.go
parent195d48d86d871f531d72e0669ea96d315845da35 (diff)
downloadpodman-b1a3b030688e28e6d7473d998cabbf923a8064f9.tar.gz
podman-b1a3b030688e28e6d7473d998cabbf923a8064f9.tar.bz2
podman-b1a3b030688e28e6d7473d998cabbf923a8064f9.zip
Update kpod pause and unpause to use new container state
Signed-off-by: umohnani8 <umohnani@redhat.com> Closes: #66 Approved by: mheon
Diffstat (limited to 'cmd/kpod/pause.go')
-rw-r--r--cmd/kpod/pause.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/cmd/kpod/pause.go b/cmd/kpod/pause.go
index 094013e6d..dede89443 100644
--- a/cmd/kpod/pause.go
+++ b/cmd/kpod/pause.go
@@ -2,10 +2,10 @@ package main
import (
"fmt"
+ "os"
+
"github.com/pkg/errors"
- "github.com/projectatomic/libpod/libkpod"
"github.com/urfave/cli"
- "os"
)
var (
@@ -24,35 +24,35 @@ var (
)
func pauseCmd(c *cli.Context) error {
+ runtime, err := getRuntime(c)
+ if err != nil {
+ return errors.Wrapf(err, "could not get runtime")
+ }
+ defer runtime.Shutdown(false)
+
args := c.Args()
if len(args) < 1 {
return errors.Errorf("you must provide at least one container name or id")
}
- config, err := getConfig(c)
- if err != nil {
- return errors.Wrapf(err, "could not get config")
- }
- server, err := libkpod.New(config)
- if err != nil {
- return errors.Wrapf(err, "could not get container server")
- }
- defer server.Shutdown()
- if err := server.Update(); err != nil {
- return errors.Wrapf(err, "could not update list of containers")
- }
var lastError error
- for _, container := range c.Args() {
- cid, err := server.ContainerPause(container)
+ for _, arg := range args {
+ ctr, err := runtime.LookupContainer(arg)
if err != nil {
if lastError != nil {
fmt.Fprintln(os.Stderr, lastError)
}
- lastError = errors.Wrapf(err, "failed to pause container %v", container)
+ lastError = errors.Wrapf(err, "error looking up container %q", arg)
+ continue
+ }
+ if err = ctr.Pause(); err != nil {
+ if lastError != nil {
+ fmt.Fprintln(os.Stderr, lastError)
+ }
+ lastError = errors.Wrapf(err, "failed to pause container %v", ctr.ID())
} else {
- fmt.Println(cid)
+ fmt.Println(ctr.ID())
}
}
-
return lastError
}