diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-05 08:52:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 08:52:09 -0800 |
commit | 3d441b5d962308372e4eba85428ac479bc140199 (patch) | |
tree | c6b3a50b846003bcaef005ad89fbe8f9e491285d /pkg/adapter/containers.go | |
parent | ac690126f8db7016a8de6f988a10a2a4a39b7301 (diff) | |
parent | 8eb4940081b30a5e05909ad1e54a5428b6886c43 (diff) | |
download | podman-3d441b5d962308372e4eba85428ac479bc140199.tar.gz podman-3d441b5d962308372e4eba85428ac479bc140199.tar.bz2 podman-3d441b5d962308372e4eba85428ac479bc140199.zip |
Merge pull request #2519 from jwhonce/wip/remote_kill
Support podman-remote kill container(s)
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 7514f30d2..fcce9bb86 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" @@ -79,3 +80,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 +} |