summaryrefslogtreecommitdiff
path: root/pkg/adapter/shortcuts/shortcuts.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-03-04 03:58:47 -0800
committerGitHub <noreply@github.com>2019-03-04 03:58:47 -0800
commitd63c8b00321f7e1d7c3cbfe3d1a57c9283d10d37 (patch)
tree93f6845030bd591e730ae315a6f3c47cc6e87dc0 /pkg/adapter/shortcuts/shortcuts.go
parentf3a3d8e28e4b8ec06dd11ec156c10e243165f19d (diff)
parent4d13a80fa46ce57e3c889934536320525338b3a4 (diff)
downloadpodman-d63c8b00321f7e1d7c3cbfe3d1a57c9283d10d37.tar.gz
podman-d63c8b00321f7e1d7c3cbfe3d1a57c9283d10d37.tar.bz2
podman-d63c8b00321f7e1d7c3cbfe3d1a57c9283d10d37.zip
Merge pull request #2364 from jwhonce/wip/remote_stop
Support podman-remote stop container
Diffstat (limited to 'pkg/adapter/shortcuts/shortcuts.go')
-rw-r--r--pkg/adapter/shortcuts/shortcuts.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/adapter/shortcuts/shortcuts.go b/pkg/adapter/shortcuts/shortcuts.go
index 0633399ae..677d88457 100644
--- a/pkg/adapter/shortcuts/shortcuts.go
+++ b/pkg/adapter/shortcuts/shortcuts.go
@@ -25,3 +25,30 @@ func GetPodsByContext(all, latest bool, pods []string, runtime *libpod.Runtime)
}
return outpods, nil
}
+
+// GetContainersByContext gets pods whether all, latest, or a slice of names/ids
+func GetContainersByContext(all, latest bool, names []string, runtime *libpod.Runtime) ([]*libpod.Container, error) {
+ var ctrs = []*libpod.Container{}
+
+ if all {
+ return runtime.GetAllContainers()
+ }
+
+ if latest {
+ c, err := runtime.GetLatestContainer()
+ if err != nil {
+ return nil, err
+ }
+ ctrs = append(ctrs, c)
+ return ctrs, nil
+ }
+
+ for _, c := range names {
+ ctr, err := runtime.LookupContainer(c)
+ if err != nil {
+ return nil, err
+ }
+ ctrs = append(ctrs, ctr)
+ }
+ return ctrs, nil
+}