diff --git a/internal/config/styles.go b/internal/config/styles.go index b58eab2d..03692289 100644 --- a/internal/config/styles.go +++ b/internal/config/styles.go @@ -69,6 +69,7 @@ type ( NewColor Color `yaml:"newColor"` ModifyColor Color `yaml:"modifyColor"` AddColor Color `yaml:"addColor"` + PendingColor Color `yaml:"pendingColor"` ErrorColor Color `yaml:"errorColor"` HighlightColor Color `yaml:"highlightColor"` KillColor Color `yaml:"killColor"` @@ -258,6 +259,7 @@ func newStatus() Status { NewColor: "lightskyblue", ModifyColor: "greenyellow", AddColor: "dodgerblue", + PendingColor: "orangered", ErrorColor: "orangered", HighlightColor: "aqua", KillColor: "mediumpurple", diff --git a/internal/render/color.go b/internal/render/color.go index b3a6e0ef..dcd2c537 100644 --- a/internal/render/color.go +++ b/internal/render/color.go @@ -11,6 +11,9 @@ var ( // AddColor row added color. AddColor tcell.Color + // PendingColor row added color. + PendingColor tcell.Color + // ErrColor row err color. ErrColor tcell.Color diff --git a/internal/render/container.go b/internal/render/container.go index e4b68907..b8369b11 100644 --- a/internal/render/container.go +++ b/internal/render/container.go @@ -37,6 +37,25 @@ type ContainerWithMetrics interface { // Container renders a K8s Container to screen. type Container struct{} +// ColorGet returns a color for a state +func ColorGet(s string,ns string, h Header, re RowEvent) tcell.Color { + switch s { + case Pending: + return PendingColor + case ContainerCreating, PodInitializing: + return AddColor + case Terminating, Initialized: + return HighlightColor + case Completed: + return CompletedColor + case Running: + return DefaultColorer(ns, h, re) + default: + return ErrColor + } + +} + // ColorerFunc colors a resource row. func (c Container) ColorerFunc() ColorerFunc { return func(ns string, h Header, re RowEvent) tcell.Color { @@ -48,18 +67,7 @@ func (c Container) ColorerFunc() ColorerFunc { if stateCol == -1 { return DefaultColorer(ns, h, re) } - switch strings.TrimSpace(re.Row.Fields[stateCol]) { - case ContainerCreating, PodInitializing: - return AddColor - case Terminating, Initialized: - return HighlightColor - case Completed: - return CompletedColor - case Running: - return DefaultColorer(ns, h, re) - default: - return ErrColor - } + return ColorGet(strings.TrimSpace(re.Row.Fields[stateCol]), ns, h, re) } } diff --git a/internal/render/pod.go b/internal/render/pod.go index 2186e70c..00a45ba8 100644 --- a/internal/render/pod.go +++ b/internal/render/pod.go @@ -30,6 +30,8 @@ func (p Pod) ColorerFunc() ColorerFunc { } status := strings.TrimSpace(re.Row.Fields[statusCol]) switch status { + case Pending: + c = PendingColor case ContainerCreating, PodInitializing: c = AddColor case Initialized: diff --git a/internal/render/types.go b/internal/render/types.go index 9790b78b..ef50fc7b 100644 --- a/internal/render/types.go +++ b/internal/render/types.go @@ -23,6 +23,9 @@ const ( // PodInitializing represents a pod initializing status. PodInitializing = "PodInitializing" + + // Pending represents a pod pending status. + Pending = "Pending" ) const ( diff --git a/internal/ui/config.go b/internal/ui/config.go index 2e426c43..772b275f 100644 --- a/internal/ui/config.go +++ b/internal/ui/config.go @@ -156,6 +156,7 @@ func (c *Configurator) updateStyles(f string) { render.AddColor = c.Styles.Frame().Status.AddColor.Color() render.ErrColor = c.Styles.Frame().Status.ErrorColor.Color() render.StdColor = c.Styles.Frame().Status.NewColor.Color() + render.PendingColor = c.Styles.Frame().Status.PendingColor.Color() render.HighlightColor = c.Styles.Frame().Status.HighlightColor.Color() render.KillColor = c.Styles.Frame().Status.KillColor.Color() render.CompletedColor = c.Styles.Frame().Status.CompletedColor.Color() diff --git a/skins/stock.yml b/skins/stock.yml index 1cb4505b..501fe6dc 100644 --- a/skins/stock.yml +++ b/skins/stock.yml @@ -23,6 +23,7 @@ k9s: modifyColor: greenyellow addColor: white errorColor: orangered + pendingColor: orangered highlightcolor: aqua killColor: mediumpurple completedColor: gray