diff options
author | Jhon Honce <jhonce@redhat.com> | 2019-03-04 10:21:51 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2019-03-04 16:37:22 -0700 |
commit | 8eb4940081b30a5e05909ad1e54a5428b6886c43 (patch) | |
tree | ae6560a3054189083b7703a18588f6831f749f09 /pkg/adapter/containers.go | |
parent | 54eecb02f050d743c7a00f5d8e2e8ffbdc26d568 (diff) | |
download | podman-8eb4940081b30a5e05909ad1e54a5428b6886c43.tar.gz podman-8eb4940081b30a5e05909ad1e54a5428b6886c43.tar.bz2 podman-8eb4940081b30a5e05909ad1e54a5428b6886c43.zip |
Support podman-remote kill container(s)
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 b0c75cf49..4975bea9c 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -4,6 +4,7 @@ package adapter import ( "context" + "syscall" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod" @@ -70,3 +71,26 @@ func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopVa } return ok, failures, nil } + +// KillContainers sends signal to container(s) based on CLI inputs. +// Returns list of successful id(s), map of failed id(s) + error, or error not from container +func (r *LocalRuntime) KillContainers(ctx context.Context, cli *cliconfig.KillValues, signal syscall.Signal) ([]string, map[string]error, error) { + var ( + ok = []string{} + failures = map[string]error{} + ) + + ctrs, err := shortcuts.GetContainersByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) + if err != nil { + return ok, failures, err + } + + for _, c := range ctrs { + if err := c.Kill(uint(signal)); err == nil { + ok = append(ok, c.ID()) + } else { + failures[c.ID()] = err + } + } + return ok, failures, nil +} |