Skip to content

Commit dfac074

Browse files
authored
feat(cli): show workspace health in list (coder#8541)
Ref coder#6461
1 parent 616e1d7 commit dfac074

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

cli/list.go

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli
22

33
import (
44
"fmt"
5+
"strconv"
56
"time"
67

78
"github.com/google/uuid"
@@ -24,6 +25,7 @@ type workspaceListRow struct {
2425
WorkspaceName string `json:"-" table:"workspace,default_sort"`
2526
Template string `json:"-" table:"template"`
2627
Status string `json:"-" table:"status"`
28+
Healthy string `json:"-" table:"healthy"`
2729
LastBuilt string `json:"-" table:"last built"`
2830
Outdated bool `json:"-" table:"outdated"`
2931
StartsAt string `json:"-" table:"starts at"`
@@ -51,12 +53,17 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
5153
}
5254
}
5355

56+
healthy := ""
57+
if status == "Starting" || status == "Started" {
58+
healthy = strconv.FormatBool(workspace.Health.Healthy)
59+
}
5460
user := usersByID[workspace.OwnerID]
5561
return workspaceListRow{
5662
Workspace: workspace,
5763
WorkspaceName: user.Username + "/" + workspace.Name,
5864
Template: workspace.TemplateName,
5965
Status: status,
66+
Healthy: healthy,
6067
LastBuilt: durationDisplay(lastBuilt),
6168
Outdated: workspace.Outdated,
6269
StartsAt: autostartDisplay,

cli/testdata/coder_list_--help.golden

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ Aliases: ls
88
-a, --all bool
99
Specifies whether all workspaces will be listed or not.
1010

11-
-c, --column string-array (default: workspace,template,status,last built,outdated,starts at,stops after)
11+
-c, --column string-array (default: workspace,template,status,healthy,last built,outdated,starts at,stops after)
1212
Columns to display in table output. Available columns: workspace,
13-
template, status, last built, outdated, starts at, stops after.
13+
template, status, healthy, last built, outdated, starts at, stops
14+
after.
1415

1516
-o, --output string (default: table)
1617
Output format. Available formats: table, json.

docs/cli/list.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ Specifies whether all workspaces will be listed or not.
2626

2727
### -c, --column
2828

29-
| | |
30-
| ------- | -------------------------------------------------------------------------------- |
31-
| Type | <code>string-array</code> |
32-
| Default | <code>workspace,template,status,last built,outdated,starts at,stops after</code> |
29+
| | |
30+
| ------- | ---------------------------------------------------------------------------------------- |
31+
| Type | <code>string-array</code> |
32+
| Default | <code>workspace,template,status,healthy,last built,outdated,starts at,stops after</code> |
3333

34-
Columns to display in table output. Available columns: workspace, template, status, last built, outdated, starts at, stops after.
34+
Columns to display in table output. Available columns: workspace, template, status, healthy, last built, outdated, starts at, stops after.
3535

3636
### -o, --output
3737

0 commit comments

Comments
 (0)