From be55dcd5e8f0773c40fdfe9a2dd84faca2f7910f Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 17 Jul 2023 09:47:04 +0000 Subject: [PATCH 1/3] feat(cli): show workspace health in list Ref #6461 --- cli/list.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/list.go b/cli/list.go index f5f6408c47199..ca1775fff4cc7 100644 --- a/cli/list.go +++ b/cli/list.go @@ -24,6 +24,7 @@ type workspaceListRow struct { WorkspaceName string `json:"-" table:"workspace,default_sort"` Template string `json:"-" table:"template"` Status string `json:"-" table:"status"` + Healthy bool `json:"-" table:"healthy"` LastBuilt string `json:"-" table:"last built"` Outdated bool `json:"-" table:"outdated"` StartsAt string `json:"-" table:"starts at"` @@ -57,6 +58,7 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders WorkspaceName: user.Username + "/" + workspace.Name, Template: workspace.TemplateName, Status: status, + Healthy: workspace.Health.Healthy, LastBuilt: durationDisplay(lastBuilt), Outdated: workspace.Outdated, StartsAt: autostartDisplay, From bfa30e56198637c826cbb603cee8a4968e9a82f6 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 17 Jul 2023 09:57:02 +0000 Subject: [PATCH 2/3] only show true/false for running workspaces --- cli/list.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/list.go b/cli/list.go index ca1775fff4cc7..4b50ba16a7d34 100644 --- a/cli/list.go +++ b/cli/list.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "strconv" "time" "github.com/google/uuid" @@ -24,7 +25,7 @@ type workspaceListRow struct { WorkspaceName string `json:"-" table:"workspace,default_sort"` Template string `json:"-" table:"template"` Status string `json:"-" table:"status"` - Healthy bool `json:"-" table:"healthy"` + Healthy string `json:"-" table:"healthy"` LastBuilt string `json:"-" table:"last built"` Outdated bool `json:"-" table:"outdated"` StartsAt string `json:"-" table:"starts at"` @@ -52,13 +53,17 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders } } + healthy := "" + if status == "Starting" || status == "Started" { + healthy = strconv.FormatBool(workspace.Health.Healthy) + } user := usersByID[workspace.OwnerID] return workspaceListRow{ Workspace: workspace, WorkspaceName: user.Username + "/" + workspace.Name, Template: workspace.TemplateName, Status: status, - Healthy: workspace.Health.Healthy, + Healthy: healthy, LastBuilt: durationDisplay(lastBuilt), Outdated: workspace.Outdated, StartsAt: autostartDisplay, From 4a2894495753931499664506c437cd71e9bad72f Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 17 Jul 2023 11:07:08 +0000 Subject: [PATCH 3/3] gen/golden --- cli/testdata/coder_list_--help.golden | 5 +++-- docs/cli/list.md | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index dfd7e69fcebfc..a9bb8218ba1c0 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -8,9 +8,10 @@ Aliases: ls -a, --all bool Specifies whether all workspaces will be listed or not. - -c, --column string-array (default: workspace,template,status,last built,outdated,starts at,stops after) + -c, --column string-array (default: workspace,template,status,healthy,last built,outdated,starts at,stops after) Columns to display in table output. Available columns: workspace, - template, status, last built, outdated, starts at, stops after. + template, status, healthy, last built, outdated, starts at, stops + after. -o, --output string (default: table) Output format. Available formats: table, json. diff --git a/docs/cli/list.md b/docs/cli/list.md index 8a7da9c9e1ac7..7a1aa0defb052 100644 --- a/docs/cli/list.md +++ b/docs/cli/list.md @@ -26,12 +26,12 @@ Specifies whether all workspaces will be listed or not. ### -c, --column -| | | -| ------- | -------------------------------------------------------------------------------- | -| Type | string-array | -| Default | workspace,template,status,last built,outdated,starts at,stops after | +| | | +| ------- | ---------------------------------------------------------------------------------------- | +| Type | string-array | +| Default | workspace,template,status,healthy,last built,outdated,starts at,stops after | -Columns to display in table output. Available columns: workspace, template, status, last built, outdated, starts at, stops after. +Columns to display in table output. Available columns: workspace, template, status, healthy, last built, outdated, starts at, stops after. ### -o, --output