lazydocker/pkg/gui/presentation/services.go
Scolliq df15d1dd99 feat: show container name alongside service name when different
When a service has a custom container_name set in docker-compose.yml
that differs from the service name, the Services panel now shows both:
  frontend (web_app)
instead of just:
  frontend

Fixes #40
2026-04-25 11:33:08 +02:00

50 lines
1.2 KiB
Go

package presentation
import (
"fmt"
"github.com/fatih/color"
"github.com/jesseduffield/lazydocker/pkg/commands"
"github.com/jesseduffield/lazydocker/pkg/config"
"github.com/jesseduffield/lazydocker/pkg/utils"
)
func GetServiceDisplayStrings(guiConfig *config.GuiConfig, service *commands.Service) []string {
if service.Container == nil {
var containerState string
switch guiConfig.ContainerStatusHealthStyle {
case "short":
containerState = "n"
case "icon":
containerState = "."
case "long":
fallthrough
default:
containerState = "none"
}
return []string{
utils.ColoredString(containerState, color.FgBlue),
"",
service.Name,
"",
"",
"",
}
}
container := service.Container
displayName := service.Name
if container.Name != "" && container.Name != service.Name {
displayName = fmt.Sprintf("%s (%s)", service.Name, container.Name)
}
return []string{
getContainerDisplayStatus(guiConfig, container),
getContainerDisplaySubstatus(guiConfig, container),
displayName,
getDisplayCPUPerc(container),
utils.ColoredString(displayPorts(container), color.FgYellow),
utils.ColoredString(displayContainerImage(container), color.FgMagenta),
}
}