diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-16 14:04:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 14:04:58 -0700 |
commit | 0d2b5532c417c58bd24e71a56c5c55b43e423a59 (patch) | |
tree | 4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/common_libpod.go | |
parent | 88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff) | |
parent | 241326a9a8c20ad7f2bcf651416b836e7778e090 (diff) | |
download | podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.gz podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.tar.bz2 podman-0d2b5532c417c58bd24e71a56c5c55b43e423a59.zip |
Merge pull request #5852 from baude/v1prune
Podman V2 birth
Diffstat (limited to 'cmd/podman/common_libpod.go')
-rw-r--r-- | cmd/podman/common_libpod.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/cmd/podman/common_libpod.go b/cmd/podman/common_libpod.go deleted file mode 100644 index b97ff5986..000000000 --- a/cmd/podman/common_libpod.go +++ /dev/null @@ -1,66 +0,0 @@ -//build !remoteclient - -package main - -import ( - "fmt" - "os" - - "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/libpod" - "github.com/containers/libpod/libpod/define" - "github.com/pkg/errors" -) - -// getAllOrLatestContainers tries to return the correct list of containers -// depending if --all, --latest or <container-id> is used. -// It requires the Context (c) and the Runtime (runtime). As different -// commands are using different container state for the --all option -// the desired state has to be specified in filterState. If no filter -// is desired a -1 can be used to get all containers. For a better -// error message, if the filter fails, a corresponding verb can be -// specified which will then appear in the error message. -func getAllOrLatestContainers(c *cliconfig.PodmanCommand, runtime *libpod.Runtime, filterState define.ContainerStatus, verb string) ([]*libpod.Container, error) { - var containers []*libpod.Container - var lastError error - var err error - switch { - case c.Bool("all"): - if filterState != -1 { - var filterFuncs []libpod.ContainerFilter - filterFuncs = append(filterFuncs, func(c *libpod.Container) bool { - state, _ := c.State() - return state == filterState - }) - containers, err = runtime.GetContainers(filterFuncs...) - } else { - containers, err = runtime.GetContainers() - } - if err != nil { - return nil, errors.Wrapf(err, "unable to get %s containers", verb) - } - case c.Bool("latest"): - lastCtr, err := runtime.GetLatestContainer() - if err != nil { - return nil, errors.Wrapf(err, "unable to get latest container") - } - containers = append(containers, lastCtr) - default: - args := c.InputArgs - 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) - } - if container != nil { - // This is here to make sure this does not return [<nil>] but only nil - containers = append(containers, container) - } - } - } - - return containers, lastError -} |