diff --git a/agent/agent.go b/agent/agent.go index 4aaef05661184..865217dd60cfe 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1200,7 +1200,7 @@ func (a *agent) createOrUpdateNetwork(manifestOK, networkOK *checkpoint) func(co network := a.network a.closeMutex.Unlock() if network == nil { - keySeed, err := SSHKeySeed(manifest.OwnerName, manifest.WorkspaceName, manifest.AgentName) + keySeed, err := SSHKeySeed(manifest.OwnerUsername, manifest.WorkspaceName, manifest.AgentName) if err != nil { return xerrors.Errorf("generate SSH key seed: %w", err) } diff --git a/cli/exp_scaletest.go b/cli/exp_scaletest.go index a844a7e8c6258..9ab18e168e16a 100644 --- a/cli/exp_scaletest.go +++ b/cli/exp_scaletest.go @@ -1027,8 +1027,8 @@ func (r *RootCmd) scaletestWorkspaceTraffic() *serpent.Command { BytesPerTick: bytesPerTick, Duration: strategy.timeout, TickInterval: tickInterval, - ReadMetrics: metrics.ReadMetrics(ws.OwnerName, ws.Name, agent.Name), - WriteMetrics: metrics.WriteMetrics(ws.OwnerName, ws.Name, agent.Name), + ReadMetrics: metrics.ReadMetrics(ws.OwnerUsername, ws.Name, agent.Name), + WriteMetrics: metrics.WriteMetrics(ws.OwnerUsername, ws.Name, agent.Name), SSH: ssh, Echo: ssh, App: appConfig, @@ -1420,7 +1420,7 @@ func isScaleTestUser(user codersdk.User) bool { } func isScaleTestWorkspace(workspace codersdk.Workspace) bool { - return strings.HasPrefix(workspace.OwnerName, "scaletest-") || + return strings.HasPrefix(workspace.OwnerUsername, "scaletest-") || strings.HasPrefix(workspace.Name, "scaletest-") } @@ -1592,7 +1592,7 @@ func createWorkspaceAppConfig(client *codersdk.Client, appHost, app string, work c.URL = fmt.Sprintf("%s://%s", client.URL.Scheme, strings.Replace(appHost, "*", agent.Apps[i].SubdomainName, 1)) } else { - c.URL = fmt.Sprintf("%s/@%s/%s.%s/apps/%s", client.URL.String(), workspace.OwnerName, workspace.Name, agent.Name, agent.Apps[i].Slug) + c.URL = fmt.Sprintf("%s/@%s/%s.%s/apps/%s", client.URL.String(), workspace.OwnerUsername, workspace.Name, agent.Name, agent.Apps[i].Slug) } return c, nil diff --git a/cli/list.go b/cli/list.go index 083d32c6e8fa1..7eb90b4b6b547 100644 --- a/cli/list.go +++ b/cli/list.go @@ -54,7 +54,7 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) if workspace.Favorite { favIco = "★" } - workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name + workspaceName := favIco + " " + workspace.OwnerUsername + "/" + workspace.Name return workspaceListRow{ Favorite: workspace.Favorite, Workspace: workspace, diff --git a/cli/open.go b/cli/open.go index ff950b552a853..1d47241564fa9 100644 --- a/cli/open.go +++ b/cli/open.go @@ -403,7 +403,7 @@ func buildVSCodeWorkspaceLink( ) (*url.URL, url.Values) { qp := url.Values{} qp.Add("url", clientURL) - qp.Add("owner", workspace.OwnerName) + qp.Add("owner", workspace.OwnerUsername) qp.Add("workspace", workspace.Name) qp.Add("agent", workspaceAgent.Name) @@ -435,7 +435,7 @@ func buildVSCodeWorkspaceDevContainerLink( qp := url.Values{} qp.Add("url", clientURL) - qp.Add("owner", workspace.OwnerName) + qp.Add("owner", workspace.OwnerUsername) qp.Add("workspace", workspace.Name) qp.Add("agent", workspaceAgent.Name) qp.Add("devContainerName", containerName) @@ -596,7 +596,7 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder u.Path = fmt.Sprintf( "%s/@%s/%s.%s/apps/%s/", preferredPathBase, - workspace.OwnerName, + workspace.OwnerUsername, workspace.Name, agent.Name, url.PathEscape(app.Slug), @@ -606,7 +606,7 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder u.Path = fmt.Sprintf( "%s/@%s/%s.%s/terminal", preferredPathBase, - workspace.OwnerName, + workspace.OwnerUsername, workspace.Name, agent.Name, ) diff --git a/cli/open_internal_test.go b/cli/open_internal_test.go index 7af4359a56bc2..7cee89ee78727 100644 --- a/cli/open_internal_test.go +++ b/cli/open_internal_test.go @@ -91,8 +91,8 @@ func Test_buildAppLinkURL(t *testing.T) { name: "without subdomain", baseURL: "https://coder.tld", workspace: codersdk.Workspace{ - Name: "Test-Workspace", - OwnerName: "username", + Name: "Test-Workspace", + OwnerUsername: "username", }, agent: codersdk.WorkspaceAgent{ Name: "a-workspace-agent", @@ -108,8 +108,8 @@ func Test_buildAppLinkURL(t *testing.T) { name: "with command", baseURL: "https://coder.tld", workspace: codersdk.Workspace{ - Name: "Test-Workspace", - OwnerName: "username", + Name: "Test-Workspace", + OwnerUsername: "username", }, agent: codersdk.WorkspaceAgent{ Name: "a-workspace-agent", @@ -123,8 +123,8 @@ func Test_buildAppLinkURL(t *testing.T) { name: "with subdomain", baseURL: "ftps://coder.tld", workspace: codersdk.Workspace{ - Name: "Test-Workspace", - OwnerName: "username", + Name: "Test-Workspace", + OwnerUsername: "username", }, agent: codersdk.WorkspaceAgent{ Name: "a-workspace-agent", @@ -141,8 +141,8 @@ func Test_buildAppLinkURL(t *testing.T) { name: "with subdomain, but not apps host", baseURL: "https://coder.tld", workspace: codersdk.Workspace{ - Name: "Test-Workspace", - OwnerName: "username", + Name: "Test-Workspace", + OwnerUsername: "username", }, agent: codersdk.WorkspaceAgent{ Name: "a-workspace-agent", diff --git a/cli/restart_test.go b/cli/restart_test.go index d69344435bf28..46d3c7b675949 100644 --- a/cli/restart_test.go +++ b/cli/restart_test.go @@ -342,7 +342,7 @@ func TestRestartWithParameters(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) @@ -393,7 +393,7 @@ func TestRestartWithParameters(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) diff --git a/cli/schedule.go b/cli/schedule.go index 9ade82b9c4a36..02445576f427f 100644 --- a/cli/schedule.go +++ b/cli/schedule.go @@ -327,7 +327,7 @@ func scheduleListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) s } } return scheduleListRow{ - WorkspaceName: workspace.OwnerName + "/" + workspace.Name, + WorkspaceName: workspace.OwnerUsername + "/" + workspace.Name, StartsAt: autostartDisplay, StartsNext: nextStartDisplay, StopsAfter: autostopDisplay, diff --git a/cli/schedule_test.go b/cli/schedule_test.go index 60fbf19f4db08..e702c0a8d65de 100644 --- a/cli/schedule_test.go +++ b/cli/schedule_test.go @@ -71,8 +71,8 @@ func setupTestSchedule(t *testing.T, sched *cron.Schedule) (ownerClient, memberC // Ensure same order as in CLI output ws = resp.Workspaces sort.Slice(ws, func(i, j int) bool { - a := ws[i].OwnerName + "/" + ws[i].Name - b := ws[j].OwnerName + "/" + ws[j].Name + a := ws[i].OwnerUsername + "/" + ws[i].Name + b := ws[j].OwnerUsername + "/" + ws[j].Name return a < b }) @@ -102,13 +102,13 @@ func TestScheduleShow(t *testing.T) { // Then: they should see their own workspaces. // 1st workspace: a-owner-ws1 has both autostart and autostop enabled. - pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) pty.ExpectMatch("8h") pty.ExpectMatch(ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) // 2nd workspace: b-owner-ws2 has only autostart enabled. - pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) }) @@ -123,21 +123,21 @@ func TestScheduleShow(t *testing.T) { // Then: they should see all workspaces // 1st workspace: a-owner-ws1 has both autostart and autostop enabled. - pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) pty.ExpectMatch("8h") pty.ExpectMatch(ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) // 2nd workspace: b-owner-ws2 has only autostart enabled. - pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) // 3rd workspace: c-member-ws3 has only autostop enabled. - pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name) pty.ExpectMatch("8h") pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) // 4th workspace: d-member-ws4 has neither autostart nor autostop enabled. - pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name) }) t.Run("OwnerSearchByName", func(t *testing.T) { @@ -150,14 +150,14 @@ func TestScheduleShow(t *testing.T) { // Then: they should see workspaces matching that query // 2nd workspace: b-owner-ws2 has only autostart enabled. - pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) }) t.Run("OwnerOneArg", func(t *testing.T) { // When: owner asks for a specific workspace by name - inv, root := clitest.New(t, "schedule", "show", ws[2].OwnerName+"/"+ws[2].Name) + inv, root := clitest.New(t, "schedule", "show", ws[2].OwnerUsername+"/"+ws[2].Name) //nolint:gocritic // Testing that owner user sees all clitest.SetupConfig(t, ownerClient, root) pty := ptytest.New(t).Attach(inv) @@ -165,7 +165,7 @@ func TestScheduleShow(t *testing.T) { // Then: they should see that workspace // 3rd workspace: c-member-ws3 has only autostop enabled. - pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name) pty.ExpectMatch("8h") pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) }) @@ -179,11 +179,11 @@ func TestScheduleShow(t *testing.T) { // Then: they should see their own workspaces // 1st workspace: c-member-ws3 has only autostop enabled. - pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name) pty.ExpectMatch("8h") pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) // 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled. - pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name) }) t.Run("MemberAll", func(t *testing.T) { @@ -200,11 +200,11 @@ func TestScheduleShow(t *testing.T) { // Then: they should only see their own // 1st workspace: c-member-ws3 has only autostop enabled. - pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name) pty.ExpectMatch("8h") pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) // 2nd workspace: d-member-ws4 has neither autostart nor autostop enabled. - pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name) }) t.Run("JSON", func(t *testing.T) { @@ -231,25 +231,25 @@ func TestScheduleShow(t *testing.T) { return a < b }) // 1st workspace: a-owner-ws1 has both autostart and autostop enabled. - assert.Equal(t, ws[0].OwnerName+"/"+ws[0].Name, parsed[0]["workspace"]) + assert.Equal(t, ws[0].OwnerUsername+"/"+ws[0].Name, parsed[0]["workspace"]) assert.Equal(t, sched.Humanize(), parsed[0]["starts_at"]) assert.Equal(t, sched.Next(now).In(loc).Format(time.RFC3339), parsed[0]["starts_next"]) assert.Equal(t, "8h", parsed[0]["stops_after"]) assert.Equal(t, ws[0].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339), parsed[0]["stops_next"]) // 2nd workspace: b-owner-ws2 has only autostart enabled. - assert.Equal(t, ws[1].OwnerName+"/"+ws[1].Name, parsed[1]["workspace"]) + assert.Equal(t, ws[1].OwnerUsername+"/"+ws[1].Name, parsed[1]["workspace"]) assert.Equal(t, sched.Humanize(), parsed[1]["starts_at"]) assert.Equal(t, sched.Next(now).In(loc).Format(time.RFC3339), parsed[1]["starts_next"]) assert.Empty(t, parsed[1]["stops_after"]) assert.Empty(t, parsed[1]["stops_next"]) // 3rd workspace: c-member-ws3 has only autostop enabled. - assert.Equal(t, ws[2].OwnerName+"/"+ws[2].Name, parsed[2]["workspace"]) + assert.Equal(t, ws[2].OwnerUsername+"/"+ws[2].Name, parsed[2]["workspace"]) assert.Empty(t, parsed[2]["starts_at"]) assert.Empty(t, parsed[2]["starts_next"]) assert.Equal(t, "8h", parsed[2]["stops_after"]) assert.Equal(t, ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339), parsed[2]["stops_next"]) // 4th workspace: d-member-ws4 has neither autostart nor autostop enabled. - assert.Equal(t, ws[3].OwnerName+"/"+ws[3].Name, parsed[3]["workspace"]) + assert.Equal(t, ws[3].OwnerUsername+"/"+ws[3].Name, parsed[3]["workspace"]) assert.Empty(t, parsed[3]["starts_at"]) assert.Empty(t, parsed[3]["starts_next"]) assert.Empty(t, parsed[3]["stops_after"]) @@ -272,7 +272,7 @@ func TestScheduleModify(t *testing.T) { t.Run("SetStart", func(t *testing.T) { // When: we set the start schedule inv, root := clitest.New(t, - "schedule", "start", ws[3].OwnerName+"/"+ws[3].Name, "7:30AM", "Mon-Fri", "Europe/Dublin", + "schedule", "start", ws[3].OwnerUsername+"/"+ws[3].Name, "7:30AM", "Mon-Fri", "Europe/Dublin", ) //nolint:gocritic // this workspace is not owned by the same user clitest.SetupConfig(t, ownerClient, root) @@ -280,7 +280,7 @@ func TestScheduleModify(t *testing.T) { require.NoError(t, inv.Run()) // Then: the updated schedule should be shown - pty.ExpectMatch(ws[3].OwnerName + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerUsername + "/" + ws[3].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) }) @@ -288,7 +288,7 @@ func TestScheduleModify(t *testing.T) { t.Run("SetStop", func(t *testing.T) { // When: we set the stop schedule inv, root := clitest.New(t, - "schedule", "stop", ws[2].OwnerName+"/"+ws[2].Name, "8h30m", + "schedule", "stop", ws[2].OwnerUsername+"/"+ws[2].Name, "8h30m", ) //nolint:gocritic // this workspace is not owned by the same user clitest.SetupConfig(t, ownerClient, root) @@ -296,7 +296,7 @@ func TestScheduleModify(t *testing.T) { require.NoError(t, inv.Run()) // Then: the updated schedule should be shown - pty.ExpectMatch(ws[2].OwnerName + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerUsername + "/" + ws[2].Name) pty.ExpectMatch("8h30m") pty.ExpectMatch(ws[2].LatestBuild.Deadline.Time.In(loc).Format(time.RFC3339)) }) @@ -304,7 +304,7 @@ func TestScheduleModify(t *testing.T) { t.Run("UnsetStart", func(t *testing.T) { // When: we unset the start schedule inv, root := clitest.New(t, - "schedule", "start", ws[1].OwnerName+"/"+ws[1].Name, "manual", + "schedule", "start", ws[1].OwnerUsername+"/"+ws[1].Name, "manual", ) //nolint:gocritic // this workspace is owned by owner clitest.SetupConfig(t, ownerClient, root) @@ -312,13 +312,13 @@ func TestScheduleModify(t *testing.T) { require.NoError(t, inv.Run()) // Then: the updated schedule should be shown - pty.ExpectMatch(ws[1].OwnerName + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerUsername + "/" + ws[1].Name) }) t.Run("UnsetStop", func(t *testing.T) { // When: we unset the stop schedule inv, root := clitest.New(t, - "schedule", "stop", ws[0].OwnerName+"/"+ws[0].Name, "manual", + "schedule", "stop", ws[0].OwnerUsername+"/"+ws[0].Name, "manual", ) //nolint:gocritic // this workspace is owned by owner clitest.SetupConfig(t, ownerClient, root) @@ -326,7 +326,7 @@ func TestScheduleModify(t *testing.T) { require.NoError(t, inv.Run()) // Then: the updated schedule should be shown - pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name) }) } @@ -359,7 +359,7 @@ func TestScheduleOverride(t *testing.T) { // When: we override the stop schedule inv, root := clitest.New(t, - "schedule", tt.command, ws[0].OwnerName+"/"+ws[0].Name, "10h", + "schedule", tt.command, ws[0].OwnerUsername+"/"+ws[0].Name, "10h", ) clitest.SetupConfig(t, ownerClient, root) @@ -367,7 +367,7 @@ func TestScheduleOverride(t *testing.T) { require.NoError(t, inv.Run()) // Then: the updated schedule should be shown - pty.ExpectMatch(ws[0].OwnerName + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerUsername + "/" + ws[0].Name) pty.ExpectMatch(sched.Humanize()) pty.ExpectMatch(sched.Next(now).In(loc).Format(time.RFC3339)) pty.ExpectMatch("8h") diff --git a/cli/ssh.go b/cli/ssh.go index 5cc81284ca317..70f00afa5614a 100644 --- a/cli/ssh.go +++ b/cli/ssh.go @@ -305,7 +305,7 @@ func (r *RootCmd) ssh() *serpent.Command { return xerrors.Errorf("get agent connection info: %w", err) } coderConnectHost := fmt.Sprintf("%s.%s.%s.%s", - workspaceAgent.Name, workspace.Name, workspace.OwnerName, connInfo.HostnameSuffix) + workspaceAgent.Name, workspace.Name, workspace.OwnerUsername, connInfo.HostnameSuffix) exists, _ := workspacesdk.ExistsViaCoderConnect(ctx, coderConnectHost) if exists { defer cancel() @@ -1022,7 +1022,7 @@ func verifyWorkspaceOutdated(client *codersdk.Client, workspace codersdk.Workspa // Build the user workspace link which navigates to the Coder web UI. func buildWorkspaceLink(serverURL *url.URL, workspace codersdk.Workspace) *url.URL { - return serverURL.ResolveReference(&url.URL{Path: fmt.Sprintf("@%s/%s", workspace.OwnerName, workspace.Name)}) + return serverURL.ResolveReference(&url.URL{Path: fmt.Sprintf("@%s/%s", workspace.OwnerUsername, workspace.Name)}) } // runLocal runs a command on the local machine. diff --git a/cli/ssh_internal_test.go b/cli/ssh_internal_test.go index 003bc697a4052..c445d4fadf44b 100644 --- a/cli/ssh_internal_test.go +++ b/cli/ssh_internal_test.go @@ -25,7 +25,7 @@ import ( ) const ( - fakeOwnerName = "fake-owner-name" + fakeOwnerUsername = "fake-owner-name" fakeServerURL = "https://fake-foo-url" fakeWorkspaceName = "fake-workspace-name" ) @@ -41,7 +41,7 @@ func TestVerifyWorkspaceOutdated(t *testing.T) { t.Run("Up-to-date", func(t *testing.T) { t.Parallel() - workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername} _, outdated := verifyWorkspaceOutdated(&client, workspace) @@ -50,7 +50,7 @@ func TestVerifyWorkspaceOutdated(t *testing.T) { t.Run("Outdated", func(t *testing.T) { t.Parallel() - workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName, Outdated: true} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername, Outdated: true} updateWorkspaceBanner, outdated := verifyWorkspaceOutdated(&client, workspace) @@ -65,10 +65,10 @@ func TestBuildWorkspaceLink(t *testing.T) { serverURL, err := url.Parse(fakeServerURL) require.NoError(t, err) - workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerUsername: fakeOwnerUsername} workspaceLink := buildWorkspaceLink(serverURL, workspace) - assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerName+"/"+fakeWorkspaceName) + assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerUsername+"/"+fakeWorkspaceName) } func TestCloserStack_Mainline(t *testing.T) { diff --git a/cli/start_test.go b/cli/start_test.go index 29fa4cdb46e5f..d15dcbd356711 100644 --- a/cli/start_test.go +++ b/cli/start_test.go @@ -148,7 +148,7 @@ func TestStart(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) @@ -191,7 +191,7 @@ func TestStart(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) @@ -247,7 +247,7 @@ func TestStartWithParameters(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) @@ -302,7 +302,7 @@ func TestStartWithParameters(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) defer cancel() - workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) actualParameters, err := client.WorkspaceBuildParameters(ctx, workspace.LatestBuild.ID) require.NoError(t, err) diff --git a/cli/testdata/coder_list_--output_json.golden b/cli/testdata/coder_list_--output_json.golden index d8e6a306cabcf..80180c6262b21 100644 --- a/cli/testdata/coder_list_--output_json.golden +++ b/cli/testdata/coder_list_--output_json.golden @@ -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", diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 416e230dfffc9..0cc518d09399f 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -17004,6 +17004,9 @@ const docTemplate = `{ "owner_name": { "type": "string" }, + "owner_username": { + "type": "string" + }, "template_active_version_id": { "type": "string", "format": "uuid" diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 4dbbf5a5fbcf9..0fdc08d22e228 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -15509,6 +15509,9 @@ "owner_name": { "type": "string" }, + "owner_username": { + "type": "string" + }, "template_active_version_id": { "type": "string", "format": "uuid" diff --git a/coderd/audit_test.go b/coderd/audit_test.go index 18bcd78b38807..c61ded694171d 100644 --- a/coderd/audit_test.go +++ b/coderd/audit_test.go @@ -139,7 +139,7 @@ func TestAuditLogs(t *testing.T) { require.NoError(t, err) buildNumberString := strconv.FormatInt(int64(workspace.LatestBuild.BuildNumber), 10) require.Equal(t, auditLogs.AuditLogs[0].ResourceLink, fmt.Sprintf("/@%s/%s/builds/%s", - workspace.OwnerName, workspace.Name, buildNumberString)) + workspace.OwnerUsername, workspace.Name, buildNumberString)) }) t.Run("Organization", func(t *testing.T) { diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 5635296d1a47b..f58c039868861 100644 --- a/coderd/workspaceagents_test.go +++ b/coderd/workspaceagents_test.go @@ -1771,7 +1771,7 @@ func TestWorkspaceAgent_Metadata(t *testing.T) { // Verify manifest API response. require.Equal(t, workspace.ID, manifest.WorkspaceID) - require.Equal(t, workspace.OwnerName, manifest.OwnerName) + require.Equal(t, workspace.OwnerUsername, manifest.OwnerUsername) require.Equal(t, "First Meta", manifest.Metadata[0].DisplayName) require.Equal(t, "foo1", manifest.Metadata[0].Key) require.Equal(t, "echo hi", manifest.Metadata[0].Script) diff --git a/coderd/workspaces.go b/coderd/workspaces.go index fe0c2d3f609a2..cb954c8690685 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -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, diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index e5a5a1e513633..fedbee56942cb 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -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) @@ -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) @@ -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) }) @@ -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) { @@ -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) diff --git a/codersdk/agentsdk/agentsdk.go b/codersdk/agentsdk/agentsdk.go index 9e6df933ce6c3..b17bb5db536e5 100644 --- a/codersdk/agentsdk/agentsdk.go +++ b/codersdk/agentsdk/agentsdk.go @@ -104,10 +104,10 @@ type PostMetadataRequestDeprecated = codersdk.WorkspaceAgentMetadataResult type Manifest struct { AgentID uuid.UUID `json:"agent_id"` AgentName string `json:"agent_name"` - // OwnerName and WorkspaceID are used by an open-source user to identify the workspace. + // OwnerUsername and WorkspaceID are used by an open-source user to identify the workspace. // We do not provide insurance that this will not be removed in the future, // but if it's easy to persist lets keep it around. - OwnerName string `json:"owner_name"` + OwnerUsername string `json:"owner_username"` WorkspaceID uuid.UUID `json:"workspace_id"` WorkspaceName string `json:"workspace_name"` // GitAuthConfigs stores the number of Git configurations diff --git a/codersdk/agentsdk/convert.go b/codersdk/agentsdk/convert.go index 2b7dff950a3e7..f67ac63f3861b 100644 --- a/codersdk/agentsdk/convert.go +++ b/codersdk/agentsdk/convert.go @@ -38,7 +38,7 @@ func ManifestFromProto(manifest *proto.Manifest) (Manifest, error) { return Manifest{ AgentID: agentID, AgentName: manifest.AgentName, - OwnerName: manifest.OwnerUsername, + OwnerUsername: manifest.OwnerUsername, WorkspaceID: workspaceID, WorkspaceName: manifest.WorkspaceName, Apps: apps, @@ -64,7 +64,7 @@ func ProtoFromManifest(manifest Manifest) (*proto.Manifest, error) { return &proto.Manifest{ AgentId: manifest.AgentID[:], AgentName: manifest.AgentName, - OwnerUsername: manifest.OwnerName, + OwnerUsername: manifest.OwnerUsername, WorkspaceId: manifest.WorkspaceID[:], WorkspaceName: manifest.WorkspaceName, // #nosec G115 - Safe conversion for GitAuthConfigs which is expected to be small and positive diff --git a/codersdk/agentsdk/convert_test.go b/codersdk/agentsdk/convert_test.go index 09482b1694910..dcafe3127a3df 100644 --- a/codersdk/agentsdk/convert_test.go +++ b/codersdk/agentsdk/convert_test.go @@ -21,7 +21,7 @@ func TestManifest(t *testing.T) { manifest := agentsdk.Manifest{ AgentID: uuid.New(), AgentName: "test-agent", - OwnerName: "test-owner", + OwnerUsername: "test-owner", WorkspaceID: uuid.New(), WorkspaceName: "test-workspace", GitAuthConfigs: 3, @@ -144,7 +144,7 @@ func TestManifest(t *testing.T) { require.NoError(t, err) require.Equal(t, manifest.AgentID, back.AgentID) require.Equal(t, manifest.AgentName, back.AgentName) - require.Equal(t, manifest.OwnerName, back.OwnerName) + require.Equal(t, manifest.OwnerUsername, back.OwnerUsername) require.Equal(t, manifest.WorkspaceID, back.WorkspaceID) require.Equal(t, manifest.WorkspaceName, back.WorkspaceName) require.Equal(t, manifest.GitAuthConfigs, back.GitAuthConfigs) diff --git a/codersdk/workspaces.go b/codersdk/workspaces.go index e0f1b9b1e2c2a..ee762ddcd3d30 100644 --- a/codersdk/workspaces.go +++ b/codersdk/workspaces.go @@ -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"` @@ -69,7 +70,7 @@ type Workspace struct { } func (w Workspace) FullName() string { - return fmt.Sprintf("%s/%s", w.OwnerName, w.Name) + return fmt.Sprintf("%s/%s", w.OwnerUsername, w.Name) } type WorkspaceHealth struct { diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index fbb23964f3d28..84681a9134530 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -8420,6 +8420,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -8457,6 +8458,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `owner_avatar_url` | string | false | | | | `owner_id` | string | false | | | | `owner_name` | string | false | | | +| `owner_username` | string | false | | | | `template_active_version_id` | string | false | | | | `template_allow_user_cancel_workspace_jobs` | boolean | false | | | | `template_display_name` | string | false | | | @@ -10123,6 +10125,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", diff --git a/docs/reference/api/workspaces.md b/docs/reference/api/workspaces.md index 1e73787dfb77e..6f3b2ec9ce76d 100644 --- a/docs/reference/api/workspaces.md +++ b/docs/reference/api/workspaces.md @@ -291,6 +291,7 @@ of the template will be used. "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -576,6 +577,7 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -887,6 +889,7 @@ of the template will be used. "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -1158,6 +1161,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \ "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -1444,6 +1448,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \ "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", @@ -1845,6 +1850,7 @@ curl -X PUT http://coder-server:8080/api/v2/workspaces/{workspace}/dormant \ "owner_avatar_url": "string", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", + "owner_username": "string", "template_active_version_id": "b0da9c29-67d8-4c87-888c-bafe356f7f3c", "template_allow_user_cancel_workspace_jobs": true, "template_display_name": "string", diff --git a/site/src/api/queries/workspaces.ts b/site/src/api/queries/workspaces.ts index 61bc7f0e70c22..b1f7aad1d792f 100644 --- a/site/src/api/queries/workspaces.ts +++ b/site/src/api/queries/workspaces.ts @@ -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, ); }, @@ -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, ), }); diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 807b6baa8b8f2..d9008c4d78919 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -3277,7 +3277,8 @@ export interface Workspace { readonly created_at: string; readonly updated_at: string; readonly owner_id: string; - readonly owner_name: string; + readonly owner_name?: string; + readonly owner_username: string; readonly owner_avatar_url: string; readonly organization_id: string; readonly organization_name: string; diff --git a/site/src/modules/apps/apps.test.ts b/site/src/modules/apps/apps.test.ts index e61b214a25385..517bc047ee815 100644 --- a/site/src/modules/apps/apps.test.ts +++ b/site/src/modules/apps/apps.test.ts @@ -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}/`, ); }); @@ -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`, ); }); @@ -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}/`, ); }); }); diff --git a/site/src/modules/apps/apps.ts b/site/src/modules/apps/apps.ts index d154b632dc1ca..47e4447725481 100644 --- a/site/src/modules/apps/apps.ts +++ b/site/src/modules/apps/apps.ts @@ -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)}`; } @@ -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)}/`; }; diff --git a/site/src/modules/resources/AgentDevcontainerCard.tsx b/site/src/modules/resources/AgentDevcontainerCard.tsx index 4891c632bbc2a..a3c3e02ac8d8a 100644 --- a/site/src/modules/resources/AgentDevcontainerCard.tsx +++ b/site/src/modules/resources/AgentDevcontainerCard.tsx @@ -142,7 +142,7 @@ export const AgentDevcontainerCard: FC = ({
= ({ workspaceName={workspace.name} agentName={agent.name} containerName={container.name} - userName={workspace.owner_name} + userName={workspace.owner_username} /> {wildcardHostname !== "" && container.ports.map((port) => { @@ -170,7 +170,7 @@ export const AgentDevcontainerCard: FC = ({ port.host_port, agent.name, workspace.name, - workspace.owner_name, + workspace.owner_username, location.protocol === "https" ? "https" : "http", ) : ""; diff --git a/site/src/modules/resources/AgentRow.tsx b/site/src/modules/resources/AgentRow.tsx index 15854cbdc23f3..40b6dcf3bea71 100644 --- a/site/src/modules/resources/AgentRow.tsx +++ b/site/src/modules/resources/AgentRow.tsx @@ -216,7 +216,7 @@ export const AgentRow: FC = ({ host={proxy.preferredWildcardHostname} workspaceName={workspace.name} agent={agent} - username={workspace.owner_name} + username={workspace.owner_username} workspaceID={workspace.id} template={template} /> @@ -239,7 +239,7 @@ export const AgentRow: FC = ({ <> {showVSCode && ( = ({ )} diff --git a/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx b/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx index fe3f274b17d24..792903da45e78 100644 --- a/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx +++ b/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx @@ -12,7 +12,7 @@ type Story = StoryObj; export const Default: Story = { args: { - userName: MockWorkspace.owner_name, + userName: MockWorkspace.owner_username, workspaceName: MockWorkspace.name, agentName: MockWorkspaceAgent.name, displayApps: [ diff --git a/site/src/modules/resources/VSCodeDevContainerButton/VSCodeDevContainerButton.stories.tsx b/site/src/modules/resources/VSCodeDevContainerButton/VSCodeDevContainerButton.stories.tsx index a16eb58ba72b3..bd4b5b378760a 100644 --- a/site/src/modules/resources/VSCodeDevContainerButton/VSCodeDevContainerButton.stories.tsx +++ b/site/src/modules/resources/VSCodeDevContainerButton/VSCodeDevContainerButton.stories.tsx @@ -12,7 +12,7 @@ type Story = StoryObj; export const Default: Story = { args: { - userName: MockWorkspace.owner_name, + userName: MockWorkspace.owner_username, workspaceName: MockWorkspace.name, agentName: MockWorkspaceAgent.name, devContainerName: "musing_ride", @@ -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", @@ -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", diff --git a/site/src/modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions.tsx b/site/src/modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions.tsx index 22e9638ee7caa..8b02dd4930d62 100644 --- a/site/src/modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions.tsx +++ b/site/src/modules/workspaces/WorkspaceMoreActions/WorkspaceMoreActions.tsx @@ -90,7 +90,7 @@ export const WorkspaceMoreActions: FC = ({ Settings diff --git a/site/src/pages/ChatPage/ChatToolInvocation.stories.tsx b/site/src/pages/ChatPage/ChatToolInvocation.stories.tsx index 03bf31cb095fb..d9b031aacb3cf 100644 --- a/site/src/pages/ChatPage/ChatToolInvocation.stories.tsx +++ b/site/src/pages/ChatPage/ChatToolInvocation.stories.tsx @@ -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, ), diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx index e5a18edbc2224..946cdf13a34b6 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx @@ -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], ); diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx index cf0e80d592cd6..477420e41fa77 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx @@ -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], ); diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index b1adcd790fe75..2acf193e1991a 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -330,7 +330,7 @@ const TasksTable: FC = ({ templates }) => { {relativeTime(new Date(workspace.created_at))} diff --git a/site/src/pages/TerminalPage/TerminalPage.stories.tsx b/site/src/pages/TerminalPage/TerminalPage.stories.tsx index 298f890637042..cda8437042c70 100644 --- a/site/src/pages/TerminalPage/TerminalPage.stories.tsx +++ b/site/src/pages/TerminalPage/TerminalPage.stories.tsx @@ -28,7 +28,7 @@ import TerminalPage from "./TerminalPage"; const createWorkspaceWithAgent = (lifecycle: WorkspaceAgentLifecycle) => { return { key: workspaceByOwnerAndNameKey( - MockWorkspace.owner_name, + MockWorkspace.owner_username, MockWorkspace.name, ), data: { @@ -54,7 +54,7 @@ const meta = { reactRouter: reactRouterParameters({ location: { pathParams: { - username: `@${MockWorkspace.owner_name}`, + username: `@${MockWorkspace.owner_username}`, workspace: MockWorkspace.name, }, }, diff --git a/site/src/pages/TerminalPage/TerminalPage.tsx b/site/src/pages/TerminalPage/TerminalPage.tsx index 9740e239233a4..b252a6e7a9641 100644 --- a/site/src/pages/TerminalPage/TerminalPage.tsx +++ b/site/src/pages/TerminalPage/TerminalPage.tsx @@ -330,7 +330,7 @@ const TerminalPage: FC = () => { {workspace.data ? pageTitle( - `Terminal · ${workspace.data.owner_name}/${workspace.data.name}`, + `Terminal · ${workspace.data.owner_username}/${workspace.data.name}`, ) : ""} diff --git a/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx b/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx index f1f1edb54a5f7..20f79c0e389bc 100644 --- a/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx +++ b/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx @@ -21,12 +21,12 @@ describe("WorkspaceBuildPage", () => { .spyOn(API, "getWorkspaceBuildByNumber") .mockResolvedValue(MockWorkspaceBuild); renderWithAuth(, { - route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, + route: `/@${MockWorkspace.owner_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, path: "/:username/:workspace/builds/:buildNumber", }); await waitFor(() => expect(getWorkspaceBuildSpy).toBeCalledWith( - MockWorkspace.owner_name, + MockWorkspace.owner_username, MockWorkspace.name, MockWorkspaceBuild.build_number, ), @@ -52,7 +52,7 @@ describe("WorkspaceBuildPage", () => { client.onmessage = async () => { renderWithAuth(, { - route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, + route: `/@${MockWorkspace.owner_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, path: "/:username/:workspace/builds/:buildNumber", }); @@ -70,7 +70,7 @@ describe("WorkspaceBuildPage", () => { }/logs?follow&after=0`, ); renderWithAuth(, { - route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}?${LOGS_TAB_KEY}=${MockWorkspaceAgent.id}`, + route: `/@${MockWorkspace.owner_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}?${LOGS_TAB_KEY}=${MockWorkspaceAgent.id}`, path: "/:username/:workspace/builds/:buildNumber", }); await screen.findByText(`Build #${MockWorkspaceBuild.build_number}`); diff --git a/site/src/pages/WorkspacePage/WorkspacePage.test.tsx b/site/src/pages/WorkspacePage/WorkspacePage.test.tsx index 3f217a86a3aad..a71e6636845ee 100644 --- a/site/src/pages/WorkspacePage/WorkspacePage.test.tsx +++ b/site/src/pages/WorkspacePage/WorkspacePage.test.tsx @@ -54,7 +54,7 @@ const renderWorkspacePage = async ( renderWithAuth(, { ...options, - route: `/@${workspace.owner_name}/${workspace.name}`, + route: `/@${workspace.owner_username}/${workspace.name}`, path: "/:username/:workspace", }); diff --git a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx index 80e2978417368..1b4625de9c4ee 100644 --- a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx @@ -184,7 +184,9 @@ export const WorkspaceReadyPage: FC = ({ return ( <> - {pageTitle(`${workspace.owner_name}/${workspace.name}`)} + + {pageTitle(`${workspace.owner_username}/${workspace.name}`)} + { const { data: workspace } = useQuery( - workspaceByOwnerAndName(MockWorkspace.owner_name, MockWorkspace.name), + workspaceByOwnerAndName(MockWorkspace.owner_username, MockWorkspace.name), ); if (!workspace) { diff --git a/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx b/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx index 5bced6f668d0f..4d117c39ee05a 100644 --- a/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx @@ -123,7 +123,7 @@ const AutostopDisplay: FC = ({ const updateWorkspaceDeadlineQueryData = (deadline: Dayjs) => { queryClient.setQueryData( - workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name), + workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name), { ...workspace, latest_build: { diff --git a/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx b/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx index 943b967de92c6..12d2f43f4fd04 100644 --- a/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx @@ -73,7 +73,7 @@ export const WorkspaceTopbar: FC = ({ // Quota const hasDailyCost = workspace.latest_build.daily_cost > 0; const { data: quota } = useQuery({ - ...workspaceQuota(workspace.organization_name, workspace.owner_name), + ...workspaceQuota(workspace.organization_name, workspace.owner_username), // Don't need to tie the enabled condition to showOrganizations because // even if the customer hasn't enabled the orgs enterprise feature, all @@ -116,7 +116,7 @@ export const WorkspaceTopbar: FC = ({
diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPage.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPage.tsx index 6dac6536b5bfb..67fe21c9d57c2 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPage.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPage.tsx @@ -39,7 +39,7 @@ const WorkspaceParametersPage: FC = () => { rich_parameter_values: buildParameters, }), onSuccess: () => { - navigate(`/${workspace.owner_name}/${workspace.name}`); + navigate(`/${workspace.owner_username}/${workspace.name}`); }, }); diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx index 781f8b12e8c67..b0af993c3b921 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx @@ -104,7 +104,7 @@ const WorkspaceParametersPageExperimental: FC = () => { rich_parameter_values: buildParameters, }), onSuccess: () => { - navigate(`/@${workspace.owner_name}/${workspace.name}`); + navigate(`/@${workspace.owner_username}/${workspace.name}`); }, }); @@ -208,7 +208,7 @@ const WorkspaceParametersPageExperimental: FC = () => { isSubmitting={updateParameters.isPending} onSubmit={handleSubmit} onCancel={() => - navigate(`/@${workspace.owner_name}/${workspace.name}`) + navigate(`/@${workspace.owner_username}/${workspace.name}`) } sendMessage={sendMessage} /> diff --git a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx index 3abb069f05d7b..becc3dcd46b3b 100644 --- a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx +++ b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx @@ -19,14 +19,14 @@ const meta: Meta = { name: "Test-Workspace-2", last_used_at: "2023-08-16T15:29:10.302441433Z", owner_id: MockUserMember.id, - owner_name: MockUserMember.username, + owner_username: MockUserMember.username, }, { ...MockWorkspace, name: "Test-Workspace-3", last_used_at: "2023-11-16T15:29:10.302441433Z", owner_id: MockUserMember.id, - owner_name: MockUserMember.username, + owner_username: MockUserMember.username, }, ], }, diff --git a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx index 587cecf25efdd..655abfbce62f9 100644 --- a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx +++ b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx @@ -174,7 +174,7 @@ const Workspaces: FC = ({ workspaces }) => { - {workspace.owner_name} + {workspace.owner_username} diff --git a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx index 76e8637ece71a..6f05b025e3d45 100644 --- a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx +++ b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx @@ -26,7 +26,7 @@ const workspaces = [ ...MockRunningOutdatedWorkspace, id: "6", owner_id: MockUserMember.id, - owner_name: MockUserMember.username, + owner_username: MockUserMember.username, }, ]; diff --git a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx index a6b0a27b374f4..e54a04a6ce8b4 100644 --- a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx +++ b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx @@ -287,7 +287,7 @@ const DormantWorkspaces: FC = ({ workspaces }) => { - {workspace.owner_name} + {workspace.owner_username} diff --git a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx index bfb159ef81c86..d25170886db3f 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx @@ -253,13 +253,13 @@ export const WorkspacesTable: FC = ({ subtitle={
Owner: - {workspace.owner_name} + {workspace.owner_username}
} avatar={ } @@ -327,7 +327,7 @@ const WorkspacesRow: FC = ({ }) => { const navigate = useNavigate(); - const workspacePageLink = `/@${workspace.owner_name}/${workspace.name}`; + const workspacePageLink = `/@${workspace.owner_username}/${workspace.name}`; const openLinkInNewTab = () => window.open(workspacePageLink, "_blank"); const { role, hover, ...clickableProps } = useClickableTableRow({ onMiddleClick: openLinkInNewTab, @@ -647,7 +647,7 @@ const WorkspaceApps: FC = ({ workspace }) => { isLoading={!token} label="Open VSCode" href={getVSCodeHref("vscode", { - owner: workspace.owner_name, + owner: workspace.owner_username, workspace: workspace.name, agent: agent.name, token: token ?? "", @@ -666,7 +666,7 @@ const WorkspaceApps: FC = ({ workspace }) => { label="Open VSCode Insiders" isLoading={!token} href={getVSCodeHref("vscode-insiders", { - owner: workspace.owner_name, + owner: workspace.owner_username, workspace: workspace.name, agent: agent.name, token: token ?? "", @@ -691,7 +691,7 @@ const WorkspaceApps: FC = ({ workspace }) => { if (builtinApps.has("web_terminal")) { const href = getTerminalHref({ - username: workspace.owner_name, + username: workspace.owner_username, workspace: workspace.name, agent: agent.name, }); diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index 7d060226b9168..76236c6ee2c6f 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -1416,7 +1416,7 @@ export const MockWorkspace: TypesGen.Workspace = { owner_id: MockUserOwner.id, organization_id: MockOrganization.id, organization_name: "default", - owner_name: MockUserOwner.username, + owner_username: MockUserOwner.username, owner_avatar_url: "https://avatars.githubusercontent.com/u/7122116?v=4", autostart_schedule: MockWorkspaceAutostartEnabled.schedule, ttl_ms: 2 * 60 * 60 * 1000,