diff options
author | Adrian Reber <areber@redhat.com> | 2018-10-16 16:39:11 +0000 |
---|---|---|
committer | Adrian Reber <adrian@lisas.de> | 2018-10-23 17:01:30 +0200 |
commit | c10ac01395066ddeb321a83ab64bc02b2e765f9a (patch) | |
tree | 1f488b0e9b5c4ea210fd1f6e1e14aef57daf4ef0 /cmd/podman/kill.go | |
parent | fea37b387c746471177f90f15b04d7735a88e621 (diff) | |
download | podman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.tar.gz podman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.tar.bz2 podman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.zip |
Use the newly added getAllOrLatestContainers() function
This removes duplicate code paths which has been previously factored out
as getAllOrLatestContainers().
Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman/kill.go')
-rw-r--r-- | cmd/podman/kill.go | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/cmd/podman/kill.go b/cmd/podman/kill.go index 37b24a923..7ca5bd7c5 100644 --- a/cmd/podman/kill.go +++ b/cmd/podman/kill.go @@ -67,39 +67,7 @@ func killCmd(c *cli.Context) error { killSignal = uint(sysSignal) } - var filterFuncs []libpod.ContainerFilter - var containers []*libpod.Container - var lastError error - if c.Bool("all") { - // only get running containers - filterFuncs = append(filterFuncs, func(c *libpod.Container) bool { - state, _ := c.State() - return state == libpod.ContainerStateRunning - }) - containers, err = runtime.GetContainers(filterFuncs...) - if err != nil { - return errors.Wrapf(err, "unable to get running containers") - } - } else if c.Bool("latest") { - lastCtr, err := runtime.GetLatestContainer() - if err != nil { - return errors.Wrapf(err, "unable to get last created container") - } - containers = append(containers, lastCtr) - } else { - args := c.Args() - for _, i := range args { - container, err := runtime.LookupContainer(i) - if err != nil { - if lastError != nil { - fmt.Fprintln(os.Stderr, lastError) - } - lastError = errors.Wrapf(err, "unable to find container %s", i) - continue - } - containers = append(containers, container) - } - } + containers, lastError := getAllOrLatestContainers(c, runtime, libpod.ContainerStateRunning, "running") for _, ctr := range containers { if err := ctr.Kill(killSignal); err != nil { |