aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2021-01-09 16:54:41 +0100
committerPaul Holzinger <paul.holzinger@web.de>2021-01-09 19:15:43 +0100
commit38baf3d5e2bc5c1e8b216dc072ea1d3eaf5053b8 (patch)
treeb471d6178b117e8ab6f287fddc8b546a04cce711 /cmd
parent1242e7b7a612b1dcae0e09a7fd10e266d34cf9e2 (diff)
downloadpodman-38baf3d5e2bc5c1e8b216dc072ea1d3eaf5053b8.tar.gz
podman-38baf3d5e2bc5c1e8b216dc072ea1d3eaf5053b8.tar.bz2
podman-38baf3d5e2bc5c1e8b216dc072ea1d3eaf5053b8.zip
Add Networks format placeholder to podman ps and pod ps
`podman ps --format {{.Networks}}` will show all connected networks for this container. For `pod ps` it will show the infra container networks. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/ps.go5
-rw-r--r--cmd/podman/pods/ps.go5
2 files changed, 10 insertions, 0 deletions
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 5d08e6163..d23771fc5 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -392,6 +392,11 @@ func (l psReporter) Names() string {
return l.ListContainer.Names[0]
}
+// Networks returns the container network names in string format
+func (l psReporter) Networks() string {
+ return strings.Join(l.ListContainer.Networks, ",")
+}
+
// Ports converts from Portmappings to the string form
// required by ps
func (l psReporter) Ports() string {
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index 99d324411..a27ab4859 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -191,6 +191,11 @@ func (l ListPodReporter) Labels() map[string]string {
return l.ListPodsReport.Labels
}
+// Networks returns the infra container network names in string format
+func (l ListPodReporter) Networks() string {
+ return strings.Join(l.ListPodsReport.Networks, ",")
+}
+
// NumberOfContainers returns an int representation for
// the number of containers belonging to the pod
func (l ListPodReporter) NumberOfContainers() int {