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:
parent
b2165b6a29
commit
ccb44c964c
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user