summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-02 05:08:22 -0800
committerGitHub <noreply@github.com>2021-03-02 05:08:22 -0800
commitc7267329bffa12df14c37e2d083c0c91ad7bb102 (patch)
tree460966e20e8bf26adfae18fa1977bd322f69ef8e /pkg
parent7497dcba6cd240908a9b0948eb561ad9c264fc8f (diff)
parent8b7caa6d04fc6a7c02bd0cbc05629508be546ac8 (diff)
downloadpodman-c7267329bffa12df14c37e2d083c0c91ad7bb102.tar.gz
podman-c7267329bffa12df14c37e2d083c0c91ad7bb102.tar.bz2
podman-c7267329bffa12df14c37e2d083c0c91ad7bb102.zip
Merge pull request #9563 from mlegenovic/master
Compat api containers/json Ports field is null
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/containers.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go
index 971b6aa50..1e84888af 100644
--- a/pkg/api/handlers/compat/containers.go
+++ b/pkg/api/handlers/compat/containers.go
@@ -307,6 +307,21 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
}
}
+ portMappings, err := l.PortMappings()
+ if err != nil {
+ return nil, err
+ }
+
+ ports := make([]types.Port, len(portMappings))
+ for idx, portMapping := range portMappings {
+ ports[idx] = types.Port{
+ IP: portMapping.HostIP,
+ PrivatePort: uint16(portMapping.ContainerPort),
+ PublicPort: uint16(portMapping.HostPort),
+ Type: portMapping.Protocol,
+ }
+ }
+
return &handlers.Container{Container: types.Container{
ID: l.ID(),
Names: []string{fmt.Sprintf("/%s", l.Name())},
@@ -314,7 +329,7 @@ func LibpodToContainer(l *libpod.Container, sz bool) (*handlers.Container, error
ImageID: imageID,
Command: strings.Join(l.Command(), " "),
Created: l.CreatedTime().Unix(),
- Ports: nil,
+ Ports: ports,
SizeRw: sizeRW,
SizeRootFs: sizeRootFs,
Labels: l.Labels(),