mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 16:11:04 +00:00
display ports against container and service
This commit is contained in:
parent
540c592b04
commit
5988ec5745
2 changed files with 12 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
|
@ -51,7 +52,15 @@ type Container struct {
|
||||||
func (c *Container) GetDisplayStrings(isFocused bool) []string {
|
func (c *Container) GetDisplayStrings(isFocused bool) []string {
|
||||||
image := strings.TrimPrefix(c.Container.Image, "sha256:")
|
image := strings.TrimPrefix(c.Container.Image, "sha256:")
|
||||||
|
|
||||||
return []string{c.GetDisplayStatus(), c.GetDisplaySubstatus(), c.Name, c.GetDisplayCPUPerc(), utils.ColoredString(image, color.FgMagenta)}
|
return []string{c.GetDisplayStatus(), c.GetDisplaySubstatus(), c.Name, c.GetDisplayCPUPerc(), utils.ColoredString(image, color.FgMagenta), c.displayPorts()}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Container) displayPorts() string {
|
||||||
|
portStrings := lo.Map(c.Container.Ports, func(port types.Port, _ int) string {
|
||||||
|
return fmt.Sprintf("%s:%d->%d/%s", port.IP, port.PublicPort, port.PrivatePort, port.Type)
|
||||||
|
})
|
||||||
|
|
||||||
|
return strings.Join(portStrings, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDisplayStatus returns the colored status of the container
|
// GetDisplayStatus returns the colored status of the container
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ type Service struct {
|
||||||
// GetDisplayStrings returns the dispaly string of Container
|
// GetDisplayStrings returns the dispaly string of Container
|
||||||
func (s *Service) GetDisplayStrings(isFocused bool) []string {
|
func (s *Service) GetDisplayStrings(isFocused bool) []string {
|
||||||
if s.Container == nil {
|
if s.Container == nil {
|
||||||
return []string{utils.ColoredString("none", color.FgBlue), "", s.Name, ""}
|
return []string{utils.ColoredString("none", color.FgBlue), "", s.Name, "", ""}
|
||||||
}
|
}
|
||||||
|
|
||||||
cont := s.Container
|
cont := s.Container
|
||||||
return []string{cont.GetDisplayStatus(), cont.GetDisplaySubstatus(), s.Name, cont.GetDisplayCPUPerc()}
|
return []string{cont.GetDisplayStatus(), cont.GetDisplaySubstatus(), s.Name, cont.GetDisplayCPUPerc(), utils.ColoredString(cont.displayPorts(), color.FgYellow)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove removes the service's containers
|
// Remove removes the service's containers
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue