aboutsummaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-07-13 14:22:43 -0400
committerMatthew Heon <mheon@redhat.com>2020-07-14 12:03:11 -0400
commit41457b5a28532d410517b1afb1759e2724d03cab (patch)
tree9d0f6a2e28c8ffdb4366bd3482b2cf5fd255be9e /libpod/util.go
parent210f1040d26334457803bc1da74667f70630a620 (diff)
downloadpodman-41457b5a28532d410517b1afb1759e2724d03cab.tar.gz
podman-41457b5a28532d410517b1afb1759e2724d03cab.tar.bz2
podman-41457b5a28532d410517b1afb1759e2724d03cab.zip
Include infra container information in `pod inspect`
We had a field for this in the inspect data, but it was never being populated. Because of this, `podman pod inspect` stopped showing port bindings (and other infra container settings). Add code to populate the infra container inspect data, and add a test to ensure we don't regress again. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 7504295f0..8c2d946ba 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -15,6 +15,7 @@ import (
"github.com/containers/common/pkg/config"
"github.com/containers/libpod/v2/libpod/define"
"github.com/containers/libpod/v2/utils"
+ "github.com/cri-o/ocicni/pkg/ocicni"
"github.com/fsnotify/fsnotify"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -254,3 +255,21 @@ func makeHTTPAttachHeader(stream byte, length uint32) []byte {
binary.BigEndian.PutUint32(header[4:], length)
return header
}
+
+// Convert OCICNI port bindings into Inspect-formatted port bindings.
+func makeInspectPortBindings(bindings []ocicni.PortMapping) map[string][]define.InspectHostPort {
+ portBindings := make(map[string][]define.InspectHostPort)
+ for _, port := range bindings {
+ key := fmt.Sprintf("%d/%s", port.ContainerPort, port.Protocol)
+ hostPorts := portBindings[key]
+ if hostPorts == nil {
+ hostPorts = []define.InspectHostPort{}
+ }
+ hostPorts = append(hostPorts, define.InspectHostPort{
+ HostIP: port.HostIP,
+ HostPort: fmt.Sprintf("%d", port.HostPort),
+ })
+ portBindings[key] = hostPorts
+ }
+ return portBindings
+}