diff options
author | Jhon Honce <jhonce@redhat.com> | 2019-03-04 17:21:23 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2019-03-06 10:32:01 -0700 |
commit | 8a6758d5fdaba9e6ec58eeb23ee5123762c18b72 (patch) | |
tree | 4273a61b912797dc6cb4d27fb6743c5367a1dfa8 /pkg/adapter/containers.go | |
parent | c6c0b54c361df623378706ca5e41faac309ab7ac (diff) | |
download | podman-8a6758d5fdaba9e6ec58eeb23ee5123762c18b72.tar.gz podman-8a6758d5fdaba9e6ec58eeb23ee5123762c18b72.tar.bz2 podman-8a6758d5fdaba9e6ec58eeb23ee5123762c18b72.zip |
Implement podman-remote wait command and container subcommand
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/adapter/containers.go')
-rw-r--r-- | pkg/adapter/containers.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index fcce9bb86..756369196 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -4,7 +4,9 @@ package adapter import ( "context" + "strconv" "syscall" + "time" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod" @@ -103,3 +105,25 @@ func (r *LocalRuntime) KillContainers(ctx context.Context, cli *cliconfig.KillVa } return ok, failures, nil } + +// WaitOnContainers waits for all given container(s) to stop +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{} + ) + + ctrs, err := shortcuts.GetContainersByContext(false, cli.Latest, cli.InputArgs, r.Runtime) + if err != nil { + return ok, failures, err + } + + for _, c := range ctrs { + if returnCode, err := c.WaitWithInterval(interval); err == nil { + ok = append(ok, strconv.Itoa(int(returnCode))) + } else { + failures[c.ID()] = err + } + } + return ok, failures, err +} |