summaryrefslogtreecommitdiff
path: root/pkg/adapter/shortcuts/shortcuts.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-04-09 17:46:28 -0700
committerGitHub <noreply@github.com>2019-04-09 17:46:28 -0700
commit60ef8f8da90ec5200e62b79b24324fefde2c7036 (patch)
treeec403dcd9b0b80d188e400a18d432539b67faf28 /pkg/adapter/shortcuts/shortcuts.go
parent40a1df38d1b6971dd1df9e06bf190c924dbad5a3 (diff)
parent09ff62429a324e01ad2c584afe9a5f66f580ae78 (diff)
downloadpodman-60ef8f8da90ec5200e62b79b24324fefde2c7036.tar.gz
podman-60ef8f8da90ec5200e62b79b24324fefde2c7036.tar.bz2
podman-60ef8f8da90ec5200e62b79b24324fefde2c7036.zip
Merge pull request #2663 from jwhonce/wip/remote_umount
Implement podman-remote umount and rm command
Diffstat (limited to 'pkg/adapter/shortcuts/shortcuts.go')
-rw-r--r--pkg/adapter/shortcuts/shortcuts.go39
1 files changed, 18 insertions, 21 deletions
diff --git a/pkg/adapter/shortcuts/shortcuts.go b/pkg/adapter/shortcuts/shortcuts.go
index 677d88457..3e4eff555 100644
--- a/pkg/adapter/shortcuts/shortcuts.go
+++ b/pkg/adapter/shortcuts/shortcuts.go
@@ -1,6 +1,8 @@
package shortcuts
-import "github.com/containers/libpod/libpod"
+import (
+ "github.com/containers/libpod/libpod"
+)
// GetPodsByContext gets pods whether all, latest, or a slice of names/ids
func GetPodsByContext(all, latest bool, pods []string, runtime *libpod.Runtime) ([]*libpod.Pod, error) {
@@ -27,28 +29,23 @@ func GetPodsByContext(all, latest bool, pods []string, runtime *libpod.Runtime)
}
// 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{}
+func GetContainersByContext(all, latest bool, names []string, runtime *libpod.Runtime) (ctrs []*libpod.Container, err error) {
+ var ctr *libpod.Container
+ 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, err = runtime.GetAllContainers()
+ } else if latest {
+ ctr, err = runtime.GetLatestContainer()
ctrs = append(ctrs, ctr)
+ } else {
+ for _, n := range names {
+ ctr, e := runtime.LookupContainer(n)
+ if e != nil && err == nil {
+ err = e
+ }
+ ctrs = append(ctrs, ctr)
+ }
}
- return ctrs, nil
+ return
}