summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers_remote.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-06 13:07:52 -0800
committerGitHub <noreply@github.com>2019-03-06 13:07:52 -0800
commit614409f64464db8022e9dc3bb0b84816ad287781 (patch)
treedf258e444b7ed91a6817e679c3af00c93afb2a2e /pkg/adapter/containers_remote.go
parent02e2342d20a01c89236b4c2f2867e6acd8eda923 (diff)
parent8a6758d5fdaba9e6ec58eeb23ee5123762c18b72 (diff)
downloadpodman-614409f64464db8022e9dc3bb0b84816ad287781.tar.gz
podman-614409f64464db8022e9dc3bb0b84816ad287781.tar.bz2
podman-614409f64464db8022e9dc3bb0b84816ad287781.zip
Merge pull request #2534 from jwhonce/wip/remote_wait
Implement podman-remote wait command and container subcommand
Diffstat (limited to 'pkg/adapter/containers_remote.go')
-rw-r--r--pkg/adapter/containers_remote.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/adapter/containers_remote.go b/pkg/adapter/containers_remote.go
index 45926ccf9..5646d2297 100644
--- a/pkg/adapter/containers_remote.go
+++ b/pkg/adapter/containers_remote.go
@@ -6,7 +6,9 @@ import (
"context"
"encoding/json"
"errors"
+ "strconv"
"syscall"
+ "time"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/shared"
@@ -173,6 +175,30 @@ func (r *LocalRuntime) KillContainers(ctx context.Context, cli *cliconfig.KillVa
return ok, failures, nil
}
+// WaitOnContainers waits for all given container(s) to stop.
+// interval is currently ignored.
+func (r *LocalRuntime) WaitOnContainers(ctx context.Context, cli *cliconfig.WaitValues, interval time.Duration) ([]string, map[string]error, error) {
+ var (
+ ok = []string{}
+ failures = map[string]error{}
+ )
+
+ ids, err := iopodman.GetContainersByContext().Call(r.Conn, false, cli.Latest, cli.InputArgs)
+ if err != nil {
+ return ok, failures, err
+ }
+
+ for _, id := range ids {
+ stopped, err := iopodman.WaitContainer().Call(r.Conn, id, int64(interval))
+ if err != nil {
+ failures[id] = err
+ } else {
+ ok = append(ok, strconv.FormatInt(stopped, 10))
+ }
+ }
+ return ok, failures, nil
+}
+
// BatchContainerOp is wrapper func to mimic shared's function with a similar name meant for libpod
func BatchContainerOp(ctr *Container, opts shared.PsOptions) (shared.BatchContainerStruct, error) {
// TODO If pod ps ever shows container's sizes, re-enable this code; otherwise it isn't needed