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

Commitbde9fd5

Browse files
authored
chore: add organization name to workspaces (#13755)
* chore: add organization name to workspaces
1 parent1286749 commitbde9fd5

File tree

13 files changed

+63
-30
lines changed

13 files changed

+63
-30
lines changed

‎cli/list.go

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strconv"
77
"time"
88

9+
"github.com/google/uuid"
910
"golang.org/x/xerrors"
1011

1112
"github.com/coder/coder/v2/cli/cliui"
@@ -22,19 +23,21 @@ type workspaceListRow struct {
2223
codersdk.Workspace`table:"-"`
2324

2425
// For table format:
25-
Favoritebool`json:"-" table:"favorite"`
26-
WorkspaceNamestring`json:"-" table:"workspace,default_sort"`
27-
Templatestring`json:"-" table:"template"`
28-
Statusstring`json:"-" table:"status"`
29-
Healthystring`json:"-" table:"healthy"`
30-
LastBuiltstring`json:"-" table:"last built"`
31-
CurrentVersionstring`json:"-" table:"current version"`
32-
Outdatedbool`json:"-" table:"outdated"`
33-
StartsAtstring`json:"-" table:"starts at"`
34-
StartsNextstring`json:"-" table:"starts next"`
35-
StopsAfterstring`json:"-" table:"stops after"`
36-
StopsNextstring`json:"-" table:"stops next"`
37-
DailyCoststring`json:"-" table:"daily cost"`
26+
Favoritebool`json:"-" table:"favorite"`
27+
WorkspaceNamestring`json:"-" table:"workspace,default_sort"`
28+
OrganizationID uuid.UUID`json:"-" table:"organization id"`
29+
OrganizationNamestring`json:"-" table:"organization name"`
30+
Templatestring`json:"-" table:"template"`
31+
Statusstring`json:"-" table:"status"`
32+
Healthystring`json:"-" table:"healthy"`
33+
LastBuiltstring`json:"-" table:"last built"`
34+
CurrentVersionstring`json:"-" table:"current version"`
35+
Outdatedbool`json:"-" table:"outdated"`
36+
StartsAtstring`json:"-" table:"starts at"`
37+
StartsNextstring`json:"-" table:"starts next"`
38+
StopsAfterstring`json:"-" table:"stops after"`
39+
StopsNextstring`json:"-" table:"stops next"`
40+
DailyCoststring`json:"-" table:"daily cost"`
3841
}
3942

4043
funcworkspaceListRowFromWorkspace(now time.Time,workspace codersdk.Workspace)workspaceListRow {
@@ -53,20 +56,22 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
5356
}
5457
workspaceName:=favIco+" "+workspace.OwnerName+"/"+workspace.Name
5558
returnworkspaceListRow{
56-
Favorite:workspace.Favorite,
57-
Workspace:workspace,
58-
WorkspaceName:workspaceName,
59-
Template:workspace.TemplateName,
60-
Status:status,
61-
Healthy:healthy,
62-
LastBuilt:durationDisplay(lastBuilt),
63-
CurrentVersion:workspace.LatestBuild.TemplateVersionName,
64-
Outdated:workspace.Outdated,
65-
StartsAt:schedRow.StartsAt,
66-
StartsNext:schedRow.StartsNext,
67-
StopsAfter:schedRow.StopsAfter,
68-
StopsNext:schedRow.StopsNext,
69-
DailyCost:strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
59+
Favorite:workspace.Favorite,
60+
Workspace:workspace,
61+
WorkspaceName:workspaceName,
62+
OrganizationID:workspace.OrganizationID,
63+
OrganizationName:workspace.OrganizationName,
64+
Template:workspace.TemplateName,
65+
Status:status,
66+
Healthy:healthy,
67+
LastBuilt:durationDisplay(lastBuilt),
68+
CurrentVersion:workspace.LatestBuild.TemplateVersionName,
69+
Outdated:workspace.Outdated,
70+
StartsAt:schedRow.StartsAt,
71+
StartsNext:schedRow.StartsNext,
72+
StopsAfter:schedRow.StopsAfter,
73+
StopsNext:schedRow.StopsNext,
74+
DailyCost:strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
7075
}
7176
}
7277

‎cli/testdata/coder_list_--help.golden

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ OPTIONS:
1313

1414
-c, --column string-array (default: workspace,template,status,healthy,last built,current version,outdated,starts at,stops after)
1515
Columns to display in table output. Available columns: favorite,
16-
workspace, template, status, healthy, last built, current version,
17-
outdated, starts at, starts next, stops after, stops next, daily cost.
16+
workspace, organization id, organization name, template, status,
17+
healthy, last built, current version, outdated, starts at, starts
18+
next, stops after, stops next, daily cost.
1819

1920
-o, --output string (default: table)
2021
Output format. Available formats: table, json.

‎cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"owner_name": "testuser",
88
"owner_avatar_url": "",
99
"organization_id": "[first org ID]",
10+
"organization_name": "first-organization",
1011
"template_id": "[template ID]",
1112
"template_name": "test-template",
1213
"template_display_name": "",

‎coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/workspaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,7 @@ func convertWorkspace(
17741774
OwnerName:username,
17751775
OwnerAvatarURL:avatarURL,
17761776
OrganizationID:workspace.OrganizationID,
1777+
OrganizationName:template.OrganizationName,
17771778
TemplateID:workspace.TemplateID,
17781779
LatestBuild:workspaceBuild,
17791780
TemplateName:template.Name,

‎coderd/workspaces_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func TestWorkspace(t *testing.T) {
6464
require.NoError(t,err)
6565
require.Equal(t,user.UserID,ws.LatestBuild.InitiatorID)
6666
require.Equal(t,codersdk.BuildReasonInitiator,ws.LatestBuild.Reason)
67+
68+
org,err:=client.Organization(ctx,ws.OrganizationID)
69+
require.NoError(t,err)
70+
require.Equal(t,ws.OrganizationName,org.Name)
6771
})
6872

6973
t.Run("Deleted",func(t*testing.T) {
@@ -1496,13 +1500,17 @@ func TestWorkspaceFilterManual(t *testing.T) {
14961500
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
14971501
defercancel()
14981502

1503+
org,err:=client.Organization(ctx,user.OrganizationID)
1504+
require.NoError(t,err)
1505+
14991506
// single workspace
15001507
res,err:=client.Workspaces(ctx, codersdk.WorkspaceFilter{
15011508
FilterQuery:fmt.Sprintf("template:%s %s/%s",template.Name,workspace.OwnerName,workspace.Name),
15021509
})
15031510
require.NoError(t,err)
15041511
require.Len(t,res.Workspaces,1)
15051512
require.Equal(t,workspace.ID,res.Workspaces[0].ID)
1513+
require.Equal(t,workspace.OrganizationName,org.Name)
15061514
})
15071515
t.Run("FilterQueryHasAgentConnecting",func(t*testing.T) {
15081516
t.Parallel()

‎codersdk/workspaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type Workspace struct {
3333
OwnerNamestring`json:"owner_name"`
3434
OwnerAvatarURLstring`json:"owner_avatar_url"`
3535
OrganizationID uuid.UUID`json:"organization_id" format:"uuid"`
36+
OrganizationNamestring`json:"organization_name"`
3637
TemplateID uuid.UUID`json:"template_id" format:"uuid"`
3738
TemplateNamestring`json:"template_name"`
3839
TemplateDisplayNamestring`json:"template_display_name"`

‎docs/api/schemas.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/api/workspaces.md

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎docs/cli/list.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎site/src/testHelpers/entities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ export const MockWorkspace: TypesGen.Workspace = {
10571057
outdated:false,
10581058
owner_id:MockUser.id,
10591059
organization_id:MockOrganization.id,
1060+
organization_name:"default",
10601061
owner_name:MockUser.username,
10611062
owner_avatar_url:"https://avatars.githubusercontent.com/u/7122116?v=4",
10621063
autostart_schedule:MockWorkspaceAutostartEnabled.schedule,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp