File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,13 +28,15 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
2828
2929 rows := []output.TableRow {}
3030 for _ , db := range databases {
31+ coloredState := commands .DatabaseStateColour (db .State ).Sprint (db .State )
32+
3133 rows = append (rows , output.TableRow {
3234 db .UUID ,
3335 db .Title ,
3436 db .Type ,
3537 db .Plan ,
3638 db .Zone ,
37- db . State ,
39+ coloredState ,
3840 })
3941 }
4042
Original file line number Diff line number Diff line change @@ -72,6 +72,18 @@ func SearchResources(
7272 return result , nil
7373}
7474
75+ // DatabaseStateColour maps database states to colours
76+ func DatabaseStateColour (state upcloud.ManagedDatabaseState ) text.Colors {
77+ switch state {
78+ case upcloud .ManagedDatabaseStateRunning :
79+ return text.Colors {text .FgGreen }
80+ case "rebuilding" , "rebalancing" :
81+ return text.Colors {text .FgYellow }
82+ default :
83+ return text.Colors {text .FgHiBlack }
84+ }
85+ }
86+
7587// ServerStateColour is a helper mapping server states to colours
7688func ServerStateColour (state string ) text.Colors {
7789 switch state {
You can’t perform that action at this time.
0 commit comments