diff options
author | baude <bbaude@redhat.com> | 2019-04-28 09:12:59 -0500 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-05-01 09:13:18 -0500 |
commit | adbc41a3f73fc5b7dcfacb3438b4ede6609f24ee (patch) | |
tree | 47395fd6da0d6747ff196e32f349218f1e0a3694 /cmd/podman/port.go | |
parent | eea77b5ae3e7fb8a60d438a79d3a4b30d35bb67c (diff) | |
download | podman-adbc41a3f73fc5b7dcfacb3438b4ede6609f24ee.tar.gz podman-adbc41a3f73fc5b7dcfacb3438b4ede6609f24ee.tar.bz2 podman-adbc41a3f73fc5b7dcfacb3438b4ede6609f24ee.zip |
podman-remote port
add the port command to the remote client. this allows users to displa
port information about their host system from the remote client
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/port.go')
-rw-r--r-- | cmd/podman/port.go | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/cmd/podman/port.go b/cmd/podman/port.go index 7a9f01fe6..1bd2d623e 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -6,8 +6,7 @@ import ( "strings" "github.com/containers/libpod/cmd/podman/cliconfig" - "github.com/containers/libpod/cmd/podman/libpodruntime" - "github.com/containers/libpod/libpod" + "github.com/containers/libpod/pkg/adapter" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -51,10 +50,7 @@ func portCmd(c *cliconfig.PortValues) error { var ( userProto, containerName string userPort int - container *libpod.Container - containers []*libpod.Container ) - args := c.InputArgs if c.Latest && c.All { @@ -66,9 +62,6 @@ func portCmd(c *cliconfig.PortValues) error { if len(args) == 0 && !c.Latest && !c.All { return errors.Errorf("you must supply a running container name or id") } - if !c.Latest && !c.All { - containerName = args[0] - } port := "" if len(args) > 1 && !c.Latest { @@ -98,36 +91,14 @@ func portCmd(c *cliconfig.PortValues) error { } } - runtime, err := libpodruntime.GetRuntime(getContext(), &c.PodmanCommand) + runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not get runtime") } defer runtime.Shutdown(false) - if !c.Latest && !c.All { - container, err = runtime.LookupContainer(containerName) - if err != nil { - return errors.Wrapf(err, "unable to find container %s", containerName) - } - containers = append(containers, container) - } else if c.Latest { - container, err = runtime.GetLatestContainer() - if err != nil { - return errors.Wrapf(err, "unable to get last created container") - } - containers = append(containers, container) - } else { - containers, err = runtime.GetRunningContainers() - if err != nil { - return errors.Wrapf(err, "unable to get all containers") - } - } - + containers, err := runtime.Port(c) for _, con := range containers { - if state, _ := con.State(); state != libpod.ContainerStateRunning { - continue - } - portmappings, err := con.PortMappings() if err != nil { return err |