Skip to content

Commit 03e5971

Browse files
committed
chore: make owner_name and owner_username consistent
1 parent 6a2f22a commit 03e5971

37 files changed

+81
-61
lines changed

cli/testdata/coder_list_--output_json.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"created_at": "====[timestamp]=====",
55
"updated_at": "====[timestamp]=====",
66
"owner_id": "==========[first user ID]===========",
7-
"owner_name": "testuser",
7+
"owner_username": "testuser",
88
"owner_avatar_url": "",
99
"organization_id": "===========[first org ID]===========",
1010
"organization_name": "coder",

coderd/apidoc/docs.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing 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 about customizing how changed files appear on GitHub.

coderd/workspaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,8 @@ func convertWorkspace(
22482248
CreatedAt: workspace.CreatedAt,
22492249
UpdatedAt: workspace.UpdatedAt,
22502250
OwnerID: workspace.OwnerID,
2251-
OwnerName: workspace.OwnerUsername,
2251+
OwnerName: workspace.OwnerName,
2252+
OwnerUsername: workspace.OwnerUsername,
22522253
OwnerAvatarURL: workspace.OwnerAvatarUrl,
22532254
OrganizationID: workspace.OrganizationID,
22542255
OrganizationName: workspace.OrganizationName,

coderd/workspaces_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,12 +1379,12 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
13791379

13801380
// Then:
13811381
// When we call without includes_deleted, we don't expect to get the workspace back
1382-
_, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
1382+
_, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
13831383
require.ErrorContains(t, err, "404")
13841384

13851385
// Then:
13861386
// When we call with includes_deleted, we should get the workspace back
1387-
workspaceNew, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
1387+
workspaceNew, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
13881388
require.NoError(t, err)
13891389
require.Equal(t, workspace.ID, workspaceNew.ID)
13901390

@@ -1402,7 +1402,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
14021402

14031403
// Then:
14041404
// We can fetch the most recent workspace
1405-
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{})
1405+
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{})
14061406
require.NoError(t, err)
14071407
require.Equal(t, workspace.ID, workspaceNew.ID)
14081408

@@ -1416,7 +1416,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {
14161416

14171417
// Then:
14181418
// When we fetch the deleted workspace, we get the most recently deleted one
1419-
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
1419+
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
14201420
require.NoError(t, err)
14211421
require.Equal(t, workspace.ID, workspaceNew.ID)
14221422
})
@@ -1901,7 +1901,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
19011901
require.NoError(t, err)
19021902
require.Len(t, res.Workspaces, len(workspaces))
19031903
for _, found := range res.Workspaces {
1904-
require.Equal(t, found.OwnerName, sdkUser.Username)
1904+
require.Equal(t, found.OwnerUsername, sdkUser.Username)
19051905
}
19061906
})
19071907
t.Run("IDs", func(t *testing.T) {
@@ -2033,7 +2033,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
20332033

20342034
// single workspace
20352035
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
2036-
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerName, workspace.Name),
2036+
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerUsername, workspace.Name),
20372037
})
20382038
require.NoError(t, err)
20392039
require.Len(t, res.Workspaces, 1)

codersdk/workspaces.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ type Workspace struct {
3030
CreatedAt time.Time `json:"created_at" format:"date-time"`
3131
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
3232
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
33-
OwnerName string `json:"owner_name"`
33+
OwnerName string `json:"owner_name,omitempty"`
34+
OwnerUsername string `json:"owner_username"`
3435
OwnerAvatarURL string `json:"owner_avatar_url"`
3536
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
3637
OrganizationName string `json:"organization_name"`

docs/reference/api/schemas.md

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

docs/reference/api/workspaces.md

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

site/src/api/queries/workspaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const activate = (workspace: Workspace, queryClient: QueryClient) => {
267267
},
268268
onSuccess: (updatedWorkspace: Workspace) => {
269269
queryClient.setQueryData(
270-
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
270+
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
271271
updatedWorkspace,
272272
);
273273
},
@@ -316,12 +316,12 @@ export const toggleFavorite = (
316316
},
317317
onSuccess: async () => {
318318
queryClient.setQueryData(
319-
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
319+
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
320320
{ ...workspace, favorite: !workspace.favorite },
321321
);
322322
await queryClient.invalidateQueries({
323323
queryKey: workspaceByOwnerAndNameKey(
324-
workspace.owner_name,
324+
workspace.owner_username,
325325
workspace.name,
326326
),
327327
});

site/src/api/typesGenerated.ts

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)