summaryrefslogtreecommitdiff
path: root/pkg/adapter/containers.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-28 09:12:59 -0500
committerbaude <bbaude@redhat.com>2019-05-01 09:13:18 -0500
commitadbc41a3f73fc5b7dcfacb3438b4ede6609f24ee (patch)
tree47395fd6da0d6747ff196e32f349218f1e0a3694 /pkg/adapter/containers.go
parenteea77b5ae3e7fb8a60d438a79d3a4b30d35bb67c (diff)
downloadpodman-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 'pkg/adapter/containers.go')
-rw-r--r--pkg/adapter/containers.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 9ec897a60..068ab3a8a 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -876,3 +876,30 @@ func cleanupContainer(ctx context.Context, ctr *libpod.Container, runtime *Local
}
return nil
}
+
+// Port displays port information about existing containers
+func (r *LocalRuntime) Port(c *cliconfig.PortValues) ([]*Container, error) {
+ var (
+ portContainers []*Container
+ containers []*libpod.Container
+ err error
+ )
+
+ if !c.All {
+ containers, err = shortcuts.GetContainersByContext(false, c.Latest, c.InputArgs, r.Runtime)
+ } else {
+ containers, err = r.Runtime.GetRunningContainers()
+ }
+ if err != nil {
+ return nil, err
+ }
+
+ //Convert libpod containers to adapter Containers
+ for _, con := range containers {
+ if state, _ := con.State(); state != libpod.ContainerStateRunning {
+ continue
+ }
+ portContainers = append(portContainers, &Container{con})
+ }
+ return portContainers, nil
+}