mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Add changes from suggestions
This commit is contained in:
parent
0c2edc7c22
commit
6adb04a364
1 changed files with 18 additions and 14 deletions
|
|
@ -258,16 +258,26 @@ func (c *Container) GetDisplayStrings(isFocused bool) []string {
|
||||||
func (c *Container) GetDisplayStatus() string {
|
func (c *Container) GetDisplayStatus() string {
|
||||||
state := c.Container.State
|
state := c.Container.State
|
||||||
if c.Container.State == "exited" {
|
if c.Container.State == "exited" {
|
||||||
state += " (" + strconv.Itoa(c.Details.State.ExitCode) + ")"
|
return utils.ColoredString(state+" ("+strconv.Itoa(c.Details.State.ExitCode)+")", c.GetColor())
|
||||||
}
|
|
||||||
if c.Container.State == "running" && c.Details.State.Health.Status != "" {
|
|
||||||
state += " (" + c.Details.State.Health.Status + ")"
|
|
||||||
}
|
|
||||||
if c.Container.State == "running" && c.Details.State.Health.Status == "unhealthy" {
|
|
||||||
return utils.MultiColoredString(state, c.GetColor(), color.BgRed)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.ColoredString(state, c.GetColor())
|
return utils.ColoredString(state, c.GetColor()) + c.healthStatusString()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Container) healthStatusString() string {
|
||||||
|
healthStatusColorMap := map[string]color.Attribute{
|
||||||
|
"healthy": color.FgGreen,
|
||||||
|
"unhealthy": color.FgRed,
|
||||||
|
"starting": color.FgYellow,
|
||||||
|
}
|
||||||
|
if c.Container.State != "running" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
healthStatus := c.Details.State.Health.Status
|
||||||
|
if healthStatusColor, ok := healthStatusColorMap[healthStatus]; ok {
|
||||||
|
return utils.ColoredString(" ("+healthStatus+")", healthStatusColor)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDisplayCPUPerc colors the cpu percentage based on how extreme it is
|
// GetDisplayCPUPerc colors the cpu percentage based on how extreme it is
|
||||||
|
|
@ -312,12 +322,6 @@ func (c *Container) GetColor() color.Attribute {
|
||||||
case "created":
|
case "created":
|
||||||
return color.FgCyan
|
return color.FgCyan
|
||||||
case "running":
|
case "running":
|
||||||
if c.Details.State.Health.Status == "starting" {
|
|
||||||
return color.FgYellow
|
|
||||||
}
|
|
||||||
if c.Details.State.Health.Status == "unhealthy" {
|
|
||||||
return color.FgBlack
|
|
||||||
}
|
|
||||||
return color.FgGreen
|
return color.FgGreen
|
||||||
case "paused":
|
case "paused":
|
||||||
return color.FgYellow
|
return color.FgYellow
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue