mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
deterministically display container ports
This commit is contained in:
parent
2134025de4
commit
10919b4dfb
1 changed files with 6 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -58,7 +59,7 @@ func (c *Container) GetDisplayStrings(isFocused bool) []string {
|
|||
func (c *Container) displayPorts() string {
|
||||
portStrings := lo.Map(c.Container.Ports, func(port types.Port, _ int) string {
|
||||
if port.PublicPort == 0 {
|
||||
return fmt.Sprintf("%d\\%s", port.PrivatePort, port.Type)
|
||||
return fmt.Sprintf("%d/%s", port.PrivatePort, port.Type)
|
||||
}
|
||||
|
||||
// docker ps will show '0.0.0.0:80->80/tcp' but we'll show
|
||||
|
|
@ -71,6 +72,10 @@ func (c *Container) displayPorts() string {
|
|||
return fmt.Sprintf("%s%d->%d/%s", ipString, port.PublicPort, port.PrivatePort, port.Type)
|
||||
})
|
||||
|
||||
// sorting because the order of the ports is not deterministic
|
||||
// and we don't want to have them constantly swapping
|
||||
sort.Strings(portStrings)
|
||||
|
||||
return strings.Join(portStrings, ", ")
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue