summaryrefslogtreecommitdiff
path: root/pkg/adapter/shortcuts
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2019-02-18 16:01:31 -0700
committerJhon Honce <jhonce@redhat.com>2019-03-02 08:57:20 -0700
commit4d13a80fa46ce57e3c889934536320525338b3a4 (patch)
tree8d3d5bd4f0209aa8ce4e3371478e6edc305209e6 /pkg/adapter/shortcuts
parent9adcda73892fa0a33cbdf971ad97cf079e8e425f (diff)
downloadpodman-4d13a80fa46ce57e3c889934536320525338b3a4.tar.gz
podman-4d13a80fa46ce57e3c889934536320525338b3a4.tar.bz2
podman-4d13a80fa46ce57e3c889934536320525338b3a4.zip
Support podman-remote stop container(s)
* Clean up adapter code * Add GetContainersByContext to Varlink API * Add missing comments * Restore save command * Restore error type mapping when using varlink Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/adapter/shortcuts')
-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
+}