mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Merge pull request #143 from jphautin/add_networks_ips
add IP of networks in single view mode
This commit is contained in:
commit
ac5bed210f
@ -80,6 +80,17 @@ func portsFormat(ports map[api.Port][]api.PortBinding) string {
|
||||
return strings.Join(append(exposed, published...), "\n")
|
||||
}
|
||||
|
||||
func ipsFormat(networks map[string]api.ContainerNetwork) string {
|
||||
var ips []string
|
||||
|
||||
for k, v := range networks {
|
||||
s := fmt.Sprintf("%s:%s", k, v.IPAddress)
|
||||
ips = append(ips, s)
|
||||
}
|
||||
|
||||
return strings.Join(ips, "\n")
|
||||
}
|
||||
|
||||
func (cm *Docker) refresh(c *container.Container) {
|
||||
insp := cm.inspect(c.Id)
|
||||
// remove container if no longer exists
|
||||
@ -89,6 +100,7 @@ func (cm *Docker) refresh(c *container.Container) {
|
||||
}
|
||||
c.SetMeta("name", shortName(insp.Name))
|
||||
c.SetMeta("image", insp.Config.Image)
|
||||
c.SetMeta("IPs", ipsFormat(insp.NetworkSettings.Networks))
|
||||
c.SetMeta("ports", portsFormat(insp.NetworkSettings.Ports))
|
||||
c.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006"))
|
||||
c.SetMeta("health", insp.State.Health.Status)
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
ui "github.com/gizak/termui"
|
||||
)
|
||||
|
||||
var displayInfo = []string{"id", "name", "image", "ports", "state", "created", "health"}
|
||||
var displayInfo = []string{"id", "name", "image", "ports", "IPs", "state", "created", "health"}
|
||||
|
||||
type Info struct {
|
||||
*ui.Table
|
||||
@ -45,7 +45,7 @@ func mkInfoRows(k, v string) (rows [][]string) {
|
||||
// initial row with field name
|
||||
rows = append(rows, []string{k, lines[0]})
|
||||
|
||||
// append any additional lines in seperate row
|
||||
// append any additional lines in separate row
|
||||
if len(lines) > 1 {
|
||||
for _, line := range lines[1:] {
|
||||
if line != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user