Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 3 commits intomainfrommafredri/feat-cli-show-healthy-in-ws-list
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionscli/list.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ package cli

import (
"fmt"
"strconv"
"time"

"github.com/google/uuid"
Expand All@@ -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"`
Expand DownExpand Up@@ -51,12 +53,17 @@ func workspaceListRowFromWorkspace(now time.Time, usersByID map[uuid.UUID]coders
}
}

healthy := ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Technically, it could be covered with unit tests.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Testing an individual column feels a bit overkill, I think this would be a good fit for a golden-file type test (we could do that for multiple commands).

Essentially, set up a server, some workspace and agents, a list of commands to run, and generate a golden file for each command.

mtojek reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm fine with leaving it as is.

mafredri reacted with thumbs up emoji
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,
Expand Down
5 changes: 3 additions & 2 deletionscli/testdata/coder_list_--help.golden
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.
Expand Down
10 changes: 5 additions & 5 deletionsdocs/cli/list.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,12 +26,12 @@ 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> |
| ||
| ------- | ---------------------------------------------------------------------------------------- |
| Type | <code>string-array</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

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp