Skip to content

Commit

Permalink
show ports at top of container config
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Jun 23, 2019
1 parent 05f931e commit 8242bd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/commands/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
14 changes: 13 additions & 1 deletion pkg/gui/containers_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 8242bd2

Please sign in to comment.