From 945cc85c2c3ee93431420d014959ed855cd5cc45 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 5 Jan 2024 15:07:10 +0000 Subject: [PATCH 1/3] feat: display current version on coder list --- cli/list.go | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/cli/list.go b/cli/list.go index c42329e033f66..c88c9a7563581 100644 --- a/cli/list.go +++ b/cli/list.go @@ -22,17 +22,18 @@ type workspaceListRow struct { codersdk.Workspace `table:"-"` // For table format: - 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"` - StartsNext string `json:"-" table:"starts next"` - StopsAfter string `json:"-" table:"stops after"` - StopsNext string `json:"-" table:"stops next"` - DailyCost string `json:"-" table:"daily cost"` + 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"` + CurrentVersion string `json:"-" table:"current version"` + Outdated bool `json:"-" table:"outdated"` + StartsAt string `json:"-" table:"starts at"` + StartsNext string `json:"-" table:"starts next"` + StopsAfter string `json:"-" table:"stops after"` + StopsNext string `json:"-" table:"stops next"` + DailyCost string `json:"-" table:"daily cost"` } func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) workspaceListRow { @@ -46,18 +47,19 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) healthy = strconv.FormatBool(workspace.Health.Healthy) } return workspaceListRow{ - Workspace: workspace, - WorkspaceName: workspace.OwnerName + "/" + workspace.Name, - Template: workspace.TemplateName, - Status: status, - Healthy: healthy, - LastBuilt: durationDisplay(lastBuilt), - Outdated: workspace.Outdated, - StartsAt: schedRow.StartsAt, - StartsNext: schedRow.StartsNext, - StopsAfter: schedRow.StopsAfter, - StopsNext: schedRow.StopsNext, - DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)), + Workspace: workspace, + WorkspaceName: workspace.OwnerName + "/" + workspace.Name, + Template: workspace.TemplateName, + Status: status, + Healthy: healthy, + LastBuilt: durationDisplay(lastBuilt), + CurrentVersion: workspace.LatestBuild.TemplateVersionName, + Outdated: workspace.Outdated, + StartsAt: schedRow.StartsAt, + StartsNext: schedRow.StartsNext, + StopsAfter: schedRow.StopsAfter, + StopsNext: schedRow.StopsNext, + DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)), } } @@ -73,6 +75,7 @@ func (r *RootCmd) list() *clibase.Cmd { "status", "healthy", "last built", + "current version", "outdated", "starts at", "stops after", From 2cfac4db15b502be147282fd1578f056fcde859f Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 5 Jan 2024 18:44:04 +0000 Subject: [PATCH 2/3] fix make gen --- docs/cli/list.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/cli/list.md b/docs/cli/list.md index ef8ef2fcaad16..9681d32c1a5a4 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,healthy,last built,outdated,starts at,stops after | +| | | +| ------- | -------------------------------------------------------------------------------------------------------- | +| Type | string-array | +| Default | workspace,template,status,healthy,last built,current version,outdated,starts at,stops after | -Columns to display in table output. Available columns: workspace, template, status, healthy, last built, outdated, starts at, starts next, stops after, stops next, daily cost. +Columns to display in table output. Available columns: workspace, template, status, healthy, last built, current version, outdated, starts at, starts next, stops after, stops next, daily cost. ### -o, --output From 14a108a93b693bd87dd924f4d084e198998ad408 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 5 Jan 2024 19:03:21 +0000 Subject: [PATCH 3/3] update golden --- cli/testdata/coder_list_--help.golden | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index a2610d8f8813b..615787278345d 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -11,10 +11,10 @@ OPTIONS: -a, --all bool Specifies whether all workspaces will be listed or not. - -c, --column string-array (default: workspace,template,status,healthy,last built,outdated,starts at,stops after) + -c, --column string-array (default: workspace,template,status,healthy,last built,current version,outdated,starts at,stops after) Columns to display in table output. Available columns: workspace, - template, status, healthy, last built, outdated, starts at, starts - next, stops after, stops next, daily cost. + template, status, healthy, last built, current version, outdated, + starts at, starts next, stops after, stops next, daily cost. -o, --output string (default: table) Output format. Available formats: table, json.