From 8242bd279ad75d5e271070f22a0c8221acab6763 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Jun 2019 19:39:45 +1000 Subject: [PATCH] show ports at top of container config --- pkg/commands/container.go | 4 +++- pkg/gui/containers_panel.go | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/commands/container.go b/pkg/commands/container.go index bb88539a..855657f6 100644 --- a/pkg/commands/container.go +++ b/pkg/commands/container.go @@ -193,7 +193,9 @@ type Details struct { HairpinMode bool `json:"HairpinMode"` LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"` LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"` - Ports struct { + Ports map[string][]struct { + HostIP string `json:"HostIP"` + HostPort string `json:"HostPort"` } `json:"Ports"` SandboxKey string `json:"SandboxKey"` SecondaryIPAddresses interface{} `json:"SecondaryIPAddresses"` diff --git a/pkg/gui/containers_panel.go b/pkg/gui/containers_panel.go index 0905bb56..9b810096 100644 --- a/pkg/gui/containers_panel.go +++ b/pkg/gui/containers_panel.go @@ -114,7 +114,7 @@ func (gui *Gui) renderContainerConfig(container *commands.Container) error { mainView.Autoscroll = false mainView.Wrap = true - padding := 15 + padding := 10 output := "" output += utils.WithPadding("ID: ", padding) + container.ID + "\n" output += utils.WithPadding("Name: ", padding) + container.Name + "\n" @@ -136,6 +136,18 @@ func (gui *Gui) renderContainerConfig(container *commands.Container) error { output += "none\n" } + output += utils.WithPadding("Ports: ", padding) + if len(container.Details.NetworkSettings.Ports) > 0 { + output += "\n" + for k, v := range container.Details.NetworkSettings.Ports { + for _, host := range v { + output += fmt.Sprintf("%s%s %s\n", strings.Repeat(" ", padding), utils.ColoredString(host.HostPort+":", color.FgYellow), k) + } + } + } else { + output += "none\n" + } + data, err := json.MarshalIndent(&container.Details, "", " ") if err != nil { return err