diff options
author | baude <bbaude@redhat.com> | 2019-06-24 15:48:34 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-06-25 13:51:24 -0500 |
commit | dd81a44ccfa34585ef62319835c8bb421db9e334 (patch) | |
tree | 7bab006a56d5823ccdf7b8cf6e59502ee954a979 /cmd/podman/common.go | |
parent | a1a4a75abee2c381483a218e1660621ee416ef7c (diff) | |
download | podman-dd81a44ccfa34585ef62319835c8bb421db9e334.tar.gz podman-dd81a44ccfa34585ef62319835c8bb421db9e334.tar.bz2 podman-dd81a44ccfa34585ef62319835c8bb421db9e334.zip |
remove libpod from main
the compilation demands of having libpod in main is a burden for the
remote client compilations. to combat this, we should move the use of
libpod structs, vars, constants, and functions into the adapter code
where it will only be compiled by the local client.
this should result in cleaner code organization and smaller binaries. it
should also help if we ever need to compile the remote client on
non-Linux operating systems natively (not cross-compiled).
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/common.go')
-rw-r--r-- | cmd/podman/common.go | 58 |
1 files changed, 3 insertions, 55 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 054b01247..7a3052653 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -9,7 +9,7 @@ import ( "github.com/containers/buildah" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/rootless" "github.com/containers/storage" "github.com/fatih/camelcase" @@ -80,58 +80,6 @@ func commandRunE() func(*cobra.Command, []string) error { } } -// 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 libpod.ContainerStatus, verb string) ([]*libpod.Container, error) { - var containers []*libpod.Container - var lastError error - var err error - if 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) - } - } else if c.Bool("latest") { - lastCtr, err := runtime.GetLatestContainer() - if err != nil { - return nil, errors.Wrapf(err, "unable to get latest container") - } - containers = append(containers, lastCtr) - } else { - 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 -} - // getContext returns a non-nil, empty context func getContext() context.Context { if Ctx != nil { @@ -333,7 +281,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { createFlags.String( "init-path", "", // Do not use the Value field for setting the default value to determine user input (i.e., non-empty string) - fmt.Sprintf("Path to the container-init binary (default: %q)", libpod.DefaultInitPath), + fmt.Sprintf("Path to the container-init binary (default: %q)", define.DefaultInitPath), ) createFlags.BoolP( "interactive", "i", false, @@ -472,7 +420,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) { "Signal to stop a container. Default is SIGTERM", ) createFlags.Uint( - "stop-timeout", libpod.CtrRemoveTimeout, + "stop-timeout", define.CtrRemoveTimeout, "Timeout (in seconds) to stop a container. Default is 10", ) createFlags.StringSlice( |