aboutsummaryrefslogtreecommitdiff
path: root/cmd/kpod/pause.go
diff options
context:
space:
mode:
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
}