mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
update port formatting for multi-line display
This commit is contained in:
parent
c76036a6f2
commit
58d5fba945
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -61,21 +62,21 @@ func (cm *DockerContainerSource) watchEvents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func portsFormat(ports map[docker.Port][]docker.PortBinding) string {
|
func portsFormat(ports map[docker.Port][]docker.PortBinding) string {
|
||||||
res := ""
|
var exposed []string
|
||||||
|
var published []string
|
||||||
|
|
||||||
for k, v := range ports {
|
for k, v := range ports {
|
||||||
res += string(k)
|
if len(v) == 0 {
|
||||||
if len(v) > 0 {
|
exposed = append(exposed, string(k))
|
||||||
res += " -> ["
|
continue
|
||||||
for i, p := range v {
|
}
|
||||||
res += p.HostPort
|
for _, binding := range v {
|
||||||
if i < len(v)-1 {
|
s := fmt.Sprintf("%s -> %s:%s", k, binding.HostIP, binding.HostPort)
|
||||||
res += ","
|
published = append(published, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res += "] "
|
|
||||||
}
|
return strings.Join(append(exposed, published...), "\n")
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm *DockerContainerSource) refresh(c *Container) {
|
func (cm *DockerContainerSource) refresh(c *Container) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user