mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add organization name to workspaces (#13755)
* chore: add organization name to workspaces
This commit is contained in:
+32
-27
@@ -6,6 +6,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/coder/coder/v2/cli/cliui"
|
||||
@@ -22,19 +23,21 @@ type workspaceListRow struct {
|
||||
codersdk.Workspace `table:"-"`
|
||||
|
||||
// For table format:
|
||||
Favorite bool `json:"-" table:"favorite"`
|
||||
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"`
|
||||
Favorite bool `json:"-" table:"favorite"`
|
||||
WorkspaceName string `json:"-" table:"workspace,default_sort"`
|
||||
OrganizationID uuid.UUID `json:"-" table:"organization id"`
|
||||
OrganizationName string `json:"-" table:"organization name"`
|
||||
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 {
|
||||
@@ -53,20 +56,22 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
|
||||
}
|
||||
workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name
|
||||
return workspaceListRow{
|
||||
Favorite: workspace.Favorite,
|
||||
Workspace: workspace,
|
||||
WorkspaceName: workspaceName,
|
||||
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)),
|
||||
Favorite: workspace.Favorite,
|
||||
Workspace: workspace,
|
||||
WorkspaceName: workspaceName,
|
||||
OrganizationID: workspace.OrganizationID,
|
||||
OrganizationName: workspace.OrganizationName,
|
||||
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)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -13,8 +13,9 @@ OPTIONS:
|
||||
|
||||
-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: favorite,
|
||||
workspace, template, status, healthy, last built, current version,
|
||||
outdated, starts at, starts next, stops after, stops next, daily cost.
|
||||
workspace, organization id, organization name, 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.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"owner_name": "testuser",
|
||||
"owner_avatar_url": "",
|
||||
"organization_id": "[first org ID]",
|
||||
"organization_name": "first-organization",
|
||||
"template_id": "[template ID]",
|
||||
"template_name": "test-template",
|
||||
"template_display_name": "",
|
||||
|
||||
Reference in New Issue
Block a user