mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
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:
@ -4,7 +4,7 @@ import (
|
|||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
var displayInfo = []string{"id", "name", "image", "state"}
|
var displayInfo = []string{"id", "name", "image", "ports", "state"}
|
||||||
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
*ui.Table
|
*ui.Table
|
||||||
|
@ -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) {
|
func (cm *DockerContainerSource) refresh(c *Container) {
|
||||||
insp := cm.inspect(c.Id)
|
insp := cm.inspect(c.Id)
|
||||||
// remove container if no longer exists
|
// remove container if no longer exists
|
||||||
@ -69,6 +87,7 @@ func (cm *DockerContainerSource) refresh(c *Container) {
|
|||||||
}
|
}
|
||||||
c.SetMeta("name", shortName(insp.Name))
|
c.SetMeta("name", shortName(insp.Name))
|
||||||
c.SetMeta("image", insp.Config.Image)
|
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.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006"))
|
||||||
c.SetState(insp.State.Status)
|
c.SetState(insp.State.Status)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user