Moved port Info to be fetched from the standard inspect call to avoid superfluous calls. Also moved the information to the info section instead of a whole new section in the expanded view

This commit is contained in:
Kenan Rhoton 2017-05-15 06:52:38 +02:00
parent b2165b6a29
commit ccb44c964c
2 changed files with 20 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import (
ui "github.com/gizak/termui"
)
var displayInfo = []string{"id", "name", "image", "state"}
var displayInfo = []string{"id", "name", "image", "ports", "state"}
type Info struct {
*ui.Table

View File

@ -60,6 +60,24 @@ func (cm *DockerContainerSource) watchEvents() {
}
}
func portsFormat(ports map[docker.Port][]docker.PortBinding) string {
res := ""
for k, v := range ports {
res += string(k)
if len(v) > 0 {
res += " -> ["
for i, p := range v {
res += p.HostPort
if i < len(v)-1 {
res += ","
}
}
res += "] "
}
}
return res
}
func (cm *DockerContainerSource) refresh(c *Container) {
insp := cm.inspect(c.Id)
// remove container if no longer exists
@ -69,6 +87,7 @@ func (cm *DockerContainerSource) refresh(c *Container) {
}
c.SetMeta("name", shortName(insp.Name))
c.SetMeta("image", insp.Config.Image)
c.SetMeta("ports", portsFormat(insp.NetworkSettings.Ports))
c.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006"))
c.SetState(insp.State.Status)
}