feat(cli): show workspace health in list (#8541)

Ref #6461
This commit is contained in:
Mathias Fredriksson
2023-07-17 15:04:06 +03:00
committed by GitHub
parent 616e1d7e9a
commit dfac0745f3
3 changed files with 15 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package cli
import (
"fmt"
"strconv"
"time"
"github.com/google/uuid"
@ -24,6 +25,7 @@ type workspaceListRow struct {
WorkspaceName string `json:"-" table:"workspace,default_sort"`
Template string `json:"-" table:"template"`
Status string `json:"-" table:"status"`
Healthy string `json:"-" table:"healthy"`
LastBuilt string `json:"-" table:"last built"`
Outdated bool `json:"-" table:"outdated"`
StartsAt string `json:"-" table:"starts at"`
@ -51,12 +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: healthy,
LastBuilt: durationDisplay(lastBuilt),
Outdated: workspace.Outdated,
StartsAt: autostartDisplay,

View File

@ -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.

View File

@ -27,11 +27,11 @@ Specifies whether all workspaces will be listed or not.
### -c, --column
| | |
| ------- | -------------------------------------------------------------------------------- |
| ------- | ---------------------------------------------------------------------------------------- |
| Type | <code>string-array</code> |
| Default | <code>workspace,template,status,last built,outdated,starts at,stops after</code> |
| Default | <code>workspace,template,status,healthy,last built,outdated,starts at,stops after</code> |
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