Skip to content

chore!: make owner_name and owner_username consistent #18081

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion cli/testdata/coder_list_--output_json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"created_at": "====[timestamp]=====",
"updated_at": "====[timestamp]=====",
"owner_id": "==========[first user ID]===========",
"owner_name": "testuser",
"owner_username": "testuser",
"owner_avatar_url": "",
"organization_id": "===========[first org ID]===========",
"organization_name": "coder",
Expand Down
3 changes: 3 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion coderd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,8 @@ func convertWorkspace(
CreatedAt: workspace.CreatedAt,
UpdatedAt: workspace.UpdatedAt,
OwnerID: workspace.OwnerID,
OwnerName: workspace.OwnerUsername,
OwnerName: workspace.OwnerName,
OwnerUsername: workspace.OwnerUsername,
OwnerAvatarURL: workspace.OwnerAvatarUrl,
OrganizationID: workspace.OrganizationID,
OrganizationName: workspace.OrganizationName,
Expand Down
12 changes: 6 additions & 6 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1379,12 +1379,12 @@ func TestWorkspaceByOwnerAndName(t *testing.T) {

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

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

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

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

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

// Then:
// When we fetch the deleted workspace, we get the most recently deleted one
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true})
require.NoError(t, err)
require.Equal(t, workspace.ID, workspaceNew.ID)
})
Expand Down Expand Up @@ -1901,7 +1901,7 @@ func TestWorkspaceFilterManual(t *testing.T) {
require.NoError(t, err)
require.Len(t, res.Workspaces, len(workspaces))
for _, found := range res.Workspaces {
require.Equal(t, found.OwnerName, sdkUser.Username)
require.Equal(t, found.OwnerUsername, sdkUser.Username)
}
})
t.Run("IDs", func(t *testing.T) {
Expand Down Expand Up @@ -2033,7 +2033,7 @@ func TestWorkspaceFilterManual(t *testing.T) {

// single workspace
res, err := client.Workspaces(ctx, codersdk.WorkspaceFilter{
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerName, workspace.Name),
FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerUsername, workspace.Name),
})
require.NoError(t, err)
require.Len(t, res.Workspaces, 1)
Expand Down
3 changes: 2 additions & 1 deletion codersdk/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type Workspace struct {
CreatedAt time.Time `json:"created_at" format:"date-time"`
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
OwnerID uuid.UUID `json:"owner_id" format:"uuid"`
OwnerName string `json:"owner_name"`
OwnerName string `json:"owner_name,omitempty"`
OwnerUsername string `json:"owner_username"`
OwnerAvatarURL string `json:"owner_avatar_url"`
OrganizationID uuid.UUID `json:"organization_id" format:"uuid"`
OrganizationName string `json:"organization_name"`
Expand Down
3 changes: 3 additions & 0 deletions docs/reference/api/schemas.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/reference/api/workspaces.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions site/src/api/queries/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const activate = (workspace: Workspace, queryClient: QueryClient) => {
},
onSuccess: (updatedWorkspace: Workspace) => {
queryClient.setQueryData(
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
updatedWorkspace,
);
},
Expand Down Expand Up @@ -316,12 +316,12 @@ export const toggleFavorite = (
},
onSuccess: async () => {
queryClient.setQueryData(
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
{ ...workspace, favorite: !workspace.favorite },
);
await queryClient.invalidateQueries({
queryKey: workspaceByOwnerAndNameKey(
workspace.owner_name,
workspace.owner_username,
workspace.name,
),
});
Expand Down
3 changes: 2 additions & 1 deletion site/src/api/typesGenerated.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions site/src/modules/apps/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe("getAppHref", () => {
path: "/path-base",
});
expect(href).toBe(
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
`/path-base/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
);
});

Expand All @@ -97,7 +97,7 @@ describe("getAppHref", () => {
path: "",
});
expect(href).toBe(
`/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`,
`/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`,
);
});

Expand Down Expand Up @@ -129,7 +129,7 @@ describe("getAppHref", () => {
path: "/path-base",
});
expect(href).toBe(
`/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
`/path-base/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`,
);
});
});
4 changes: 2 additions & 2 deletions site/src/modules/apps/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const getAppHref = (
// Terminal links are relative. The terminal page knows how
// to select the correct workspace proxy for the websocket
// connection.
return `/@${workspace.owner_name}/${workspace.name}.${
return `/@${workspace.owner_username}/${workspace.name}.${
agent.name
}/terminal?command=${encodeURIComponent(app.command)}`;
}
Expand All @@ -119,7 +119,7 @@ export const getAppHref = (

// The backend redirects if the trailing slash isn't included, so we add it
// here to avoid extra roundtrips.
return `${path}/@${workspace.owner_name}/${workspace.name}.${
return `${path}/@${workspace.owner_username}/${workspace.name}.${
agent.name
}/apps/${encodeURIComponent(app.slug)}/`;
};
Expand Down
6 changes: 3 additions & 3 deletions site/src/modules/resources/AgentDevcontainerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({

<div className="flex gap-4 flex-wrap mt-4">
<VSCodeDevContainerButton
userName={workspace.owner_name}
userName={workspace.owner_username}
workspaceName={workspace.name}
devContainerName={container.name}
devContainerFolder={containerFolder}
Expand All @@ -154,7 +154,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
workspaceName={workspace.name}
agentName={agent.name}
containerName={container.name}
userName={workspace.owner_name}
userName={workspace.owner_username}
/>
{wildcardHostname !== "" &&
container.ports.map((port) => {
Expand All @@ -170,7 +170,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
port.host_port,
agent.name,
workspace.name,
workspace.owner_name,
workspace.owner_username,
location.protocol === "https" ? "https" : "http",
)
: "";
Expand Down
6 changes: 3 additions & 3 deletions site/src/modules/resources/AgentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const AgentRow: FC<AgentRowProps> = ({
host={proxy.preferredWildcardHostname}
workspaceName={workspace.name}
agent={agent}
username={workspace.owner_name}
username={workspace.owner_username}
workspaceID={workspace.id}
template={template}
/>
Expand All @@ -239,7 +239,7 @@ export const AgentRow: FC<AgentRowProps> = ({
<>
{showVSCode && (
<VSCodeDesktopButton
userName={workspace.owner_name}
userName={workspace.owner_username}
workspaceName={workspace.name}
agentName={agent.name}
folderPath={agent.expanded_directory}
Expand All @@ -261,7 +261,7 @@ export const AgentRow: FC<AgentRowProps> = ({
<TerminalLink
workspaceName={workspace.name}
agentName={agent.name}
userName={workspace.owner_name}
userName={workspace.owner_username}
/>
)}
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDesktopButton>;

export const Default: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
displayApps: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDevContainerButton>;

export const Default: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
devContainerName: "musing_ride",
Expand All @@ -29,7 +29,7 @@ export const Default: Story = {

export const VSCodeOnly: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
devContainerName: "nifty_borg",
Expand All @@ -45,7 +45,7 @@ export const VSCodeOnly: Story = {

export const InsidersOnly: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
devContainerName: "amazing_swartz",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const WorkspaceMoreActions: FC<WorkspaceMoreActionsProps> = ({
<DropdownMenuContent id="workspace-options" align="end">
<DropdownMenuItem asChild>
<RouterLink
to={`/@${workspace.owner_name}/${workspace.name}/settings`}
to={`/@${workspace.owner_username}/${workspace.name}/settings`}
>
<SettingsIcon />
Settings
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/ChatPage/ChatToolInvocation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const CreateWorkspace: Story = {
name: MockWorkspace.name,
rich_parameters: {},
template_version_id: MockWorkspace.template_active_version_id,
user: MockWorkspace.owner_name,
user: MockWorkspace.owner_username,
},
MockWorkspace,
),
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const CreateWorkspacePage: FC = () => {

const onCreateWorkspace = useCallback(
(workspace: Workspace) => {
navigate(`/@${workspace.owner_name}/${workspace.name}`);
navigate(`/@${workspace.owner_username}/${workspace.name}`);
},
[navigate],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ const CreateWorkspacePageExperimental: FC = () => {

const onCreateWorkspace = useCallback(
(workspace: Workspace) => {
navigate(`/@${workspace.owner_name}/${workspace.name}`);
navigate(`/@${workspace.owner_username}/${workspace.name}`);
},
[navigate],
);
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/TasksPage/TasksPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ const TasksTable: FC<TasksTableProps> = ({ templates }) => {
</TableCell>
<TableCell>
<AvatarData
title={workspace.owner_name}
title={workspace.owner_username}
subtitle={
<span className="block first-letter:uppercase">
{relativeTime(new Date(workspace.created_at))}
Expand Down
Loading
Loading