diff --git a/agent/agent.go b/agent/agent.go index 27219c7ef0c1e..a971c0e7987b6 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.OwnerUsername, manifest.WorkspaceName, manifest.AgentName) + keySeed, err := SSHKeySeed(manifest.OwnerName, 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 9ab18e168e16a..a844a7e8c6258 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.OwnerUsername, ws.Name, agent.Name), - WriteMetrics: metrics.WriteMetrics(ws.OwnerUsername, ws.Name, agent.Name), + ReadMetrics: metrics.ReadMetrics(ws.OwnerName, ws.Name, agent.Name), + WriteMetrics: metrics.WriteMetrics(ws.OwnerName, 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.OwnerUsername, "scaletest-") || + return strings.HasPrefix(workspace.OwnerName, "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.OwnerUsername, workspace.Name, agent.Name, agent.Apps[i].Slug) + c.URL = fmt.Sprintf("%s/@%s/%s.%s/apps/%s", client.URL.String(), workspace.OwnerName, workspace.Name, agent.Name, agent.Apps[i].Slug) } return c, nil diff --git a/cli/list.go b/cli/list.go index 7eb90b4b6b547..083d32c6e8fa1 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.OwnerUsername + "/" + workspace.Name + workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name return workspaceListRow{ Favorite: workspace.Favorite, Workspace: workspace, diff --git a/cli/open.go b/cli/open.go index 1d47241564fa9..ff950b552a853 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.OwnerUsername) + qp.Add("owner", workspace.OwnerName) 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.OwnerUsername) + qp.Add("owner", workspace.OwnerName) 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.OwnerUsername, + workspace.OwnerName, 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.OwnerUsername, + workspace.OwnerName, workspace.Name, agent.Name, ) diff --git a/cli/open_internal_test.go b/cli/open_internal_test.go index 7cee89ee78727..7af4359a56bc2 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", - OwnerUsername: "username", + Name: "Test-Workspace", + OwnerName: "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", - OwnerUsername: "username", + Name: "Test-Workspace", + OwnerName: "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", - OwnerUsername: "username", + Name: "Test-Workspace", + OwnerName: "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", - OwnerUsername: "username", + Name: "Test-Workspace", + OwnerName: "username", }, agent: codersdk.WorkspaceAgent{ Name: "a-workspace-agent", diff --git a/cli/restart_test.go b/cli/restart_test.go index 46d3c7b675949..d69344435bf28 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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 02445576f427f..9ade82b9c4a36 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.OwnerUsername + "/" + workspace.Name, + WorkspaceName: workspace.OwnerName + "/" + workspace.Name, StartsAt: autostartDisplay, StartsNext: nextStartDisplay, StopsAfter: autostopDisplay, diff --git a/cli/schedule_test.go b/cli/schedule_test.go index e702c0a8d65de..60fbf19f4db08 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].OwnerUsername + "/" + ws[i].Name - b := ws[j].OwnerUsername + "/" + ws[j].Name + a := ws[i].OwnerName + "/" + ws[i].Name + b := ws[j].OwnerName + "/" + 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].OwnerUsername + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerName + "/" + 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].OwnerUsername + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerName + "/" + 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].OwnerUsername + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerName + "/" + 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].OwnerUsername + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerName + "/" + 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].OwnerUsername + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerName + "/" + 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].OwnerUsername + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerName + "/" + 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].OwnerUsername + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerName + "/" + 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].OwnerUsername+"/"+ws[2].Name) + inv, root := clitest.New(t, "schedule", "show", ws[2].OwnerName+"/"+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].OwnerUsername + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerName + "/" + 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].OwnerUsername + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerName + "/" + 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].OwnerUsername + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerName + "/" + 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].OwnerUsername + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerName + "/" + 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].OwnerUsername + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerName + "/" + 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].OwnerUsername+"/"+ws[0].Name, parsed[0]["workspace"]) + assert.Equal(t, ws[0].OwnerName+"/"+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].OwnerUsername+"/"+ws[1].Name, parsed[1]["workspace"]) + assert.Equal(t, ws[1].OwnerName+"/"+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].OwnerUsername+"/"+ws[2].Name, parsed[2]["workspace"]) + assert.Equal(t, ws[2].OwnerName+"/"+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].OwnerUsername+"/"+ws[3].Name, parsed[3]["workspace"]) + assert.Equal(t, ws[3].OwnerName+"/"+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].OwnerUsername+"/"+ws[3].Name, "7:30AM", "Mon-Fri", "Europe/Dublin", + "schedule", "start", ws[3].OwnerName+"/"+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].OwnerUsername + "/" + ws[3].Name) + pty.ExpectMatch(ws[3].OwnerName + "/" + 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].OwnerUsername+"/"+ws[2].Name, "8h30m", + "schedule", "stop", ws[2].OwnerName+"/"+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].OwnerUsername + "/" + ws[2].Name) + pty.ExpectMatch(ws[2].OwnerName + "/" + 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].OwnerUsername+"/"+ws[1].Name, "manual", + "schedule", "start", ws[1].OwnerName+"/"+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].OwnerUsername + "/" + ws[1].Name) + pty.ExpectMatch(ws[1].OwnerName + "/" + 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].OwnerUsername+"/"+ws[0].Name, "manual", + "schedule", "stop", ws[0].OwnerName+"/"+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].OwnerUsername + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerName + "/" + 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].OwnerUsername+"/"+ws[0].Name, "10h", + "schedule", tt.command, ws[0].OwnerName+"/"+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].OwnerUsername + "/" + ws[0].Name) + pty.ExpectMatch(ws[0].OwnerName + "/" + 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 f16cbba9316b7..51f53e10bcbd2 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.OwnerUsername, connInfo.HostnameSuffix) + workspaceAgent.Name, workspace.Name, workspace.OwnerName, 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.OwnerUsername, workspace.Name)}) + return serverURL.ResolveReference(&url.URL{Path: fmt.Sprintf("@%s/%s", workspace.OwnerName, 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 c445d4fadf44b..003bc697a4052 100644 --- a/cli/ssh_internal_test.go +++ b/cli/ssh_internal_test.go @@ -25,7 +25,7 @@ import ( ) const ( - fakeOwnerUsername = "fake-owner-name" + fakeOwnerName = "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, OwnerUsername: fakeOwnerUsername} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName} _, 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, OwnerUsername: fakeOwnerUsername, Outdated: true} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName, 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, OwnerUsername: fakeOwnerUsername} + workspace := codersdk.Workspace{Name: fakeWorkspaceName, OwnerName: fakeOwnerName} workspaceLink := buildWorkspaceLink(serverURL, workspace) - assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerUsername+"/"+fakeWorkspaceName) + assert.Equal(t, workspaceLink.String(), fakeServerURL+"/@"+fakeOwnerName+"/"+fakeWorkspaceName) } func TestCloserStack_Mainline(t *testing.T) { diff --git a/cli/start_test.go b/cli/start_test.go index d15dcbd356711..29fa4cdb46e5f 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspace, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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 80180c6262b21..d8e6a306cabcf 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_username": "testuser", + "owner_name": "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 aff8724f098c6..5e8b8d6afa89e 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -17019,9 +17019,7 @@ const docTemplate = `{ "format": "uuid" }, "owner_name": { - "type": "string" - }, - "owner_username": { + "description": "OwnerName is the username of the owner of the workspace.", "type": "string" }, "template_active_version_id": { diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 513dc80f96fc0..ef32dcd24f375 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -15524,9 +15524,7 @@ "format": "uuid" }, "owner_name": { - "type": "string" - }, - "owner_username": { + "description": "OwnerName is the username of the owner of the workspace.", "type": "string" }, "template_active_version_id": { diff --git a/coderd/audit.go b/coderd/audit.go index ee647fba2f39b..63b6e49ebb05a 100644 --- a/coderd/audit.go +++ b/coderd/audit.go @@ -462,7 +462,7 @@ func (api *API) auditLogResourceLink(ctx context.Context, alog database.GetAudit if getWorkspaceErr != nil { return "" } - return fmt.Sprintf("/@%s/%s", workspace.OwnerUsername, workspace.Name) + return fmt.Sprintf("/@%s/%s", workspace.OwnerName, workspace.Name) case database.ResourceTypeWorkspaceApp: if additionalFields.WorkspaceOwner != "" && additionalFields.WorkspaceName != "" { @@ -472,7 +472,7 @@ func (api *API) auditLogResourceLink(ctx context.Context, alog database.GetAudit if getWorkspaceErr != nil { return "" } - return fmt.Sprintf("/@%s/%s", workspace.OwnerUsername, workspace.Name) + return fmt.Sprintf("/@%s/%s", workspace.OwnerName, workspace.Name) case database.ResourceTypeOauth2ProviderApp: return fmt.Sprintf("/deployment/oauth2-provider/apps/%s", alog.AuditLog.ResourceID) diff --git a/coderd/audit_test.go b/coderd/audit_test.go index c61ded694171d..18bcd78b38807 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.OwnerUsername, workspace.Name, buildNumberString)) + workspace.OwnerName, workspace.Name, buildNumberString)) }) t.Run("Organization", func(t *testing.T) { diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 7137dc16a1b43..a9b981f820be2 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.OwnerUsername, manifest.OwnerUsername) + require.Equal(t, workspace.OwnerName, manifest.OwnerName) 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 cb954c8690685..fe0c2d3f609a2 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -2248,8 +2248,7 @@ func convertWorkspace( CreatedAt: workspace.CreatedAt, UpdatedAt: workspace.UpdatedAt, OwnerID: workspace.OwnerID, - OwnerName: workspace.OwnerName, - OwnerUsername: workspace.OwnerUsername, + OwnerName: workspace.OwnerUsername, OwnerAvatarURL: workspace.OwnerAvatarUrl, OrganizationID: workspace.OrganizationID, OrganizationName: workspace.OrganizationName, diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 3990fbd9185b7..018dd363bdee6 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -1380,12 +1380,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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + _, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, 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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true}) + workspaceNew, err := client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true}) require.NoError(t, err) require.Equal(t, workspace.ID, workspaceNew.ID) @@ -1403,7 +1403,7 @@ func TestWorkspaceByOwnerAndName(t *testing.T) { // Then: // We can fetch the most recent workspace - workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{}) + workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{}) require.NoError(t, err) require.Equal(t, workspace.ID, workspaceNew.ID) @@ -1417,7 +1417,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.OwnerUsername, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true}) + workspaceNew, err = client.WorkspaceByOwnerAndName(ctx, workspace.OwnerName, workspace.Name, codersdk.WorkspaceOptions{IncludeDeleted: true}) require.NoError(t, err) require.Equal(t, workspace.ID, workspaceNew.ID) }) @@ -1902,7 +1902,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.OwnerUsername, sdkUser.Username) + require.Equal(t, found.OwnerName, sdkUser.Username) } }) t.Run("IDs", func(t *testing.T) { @@ -2034,7 +2034,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.OwnerUsername, workspace.Name), + FilterQuery: fmt.Sprintf("template:%s %s/%s", template.Name, workspace.OwnerName, 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 1178a193a21a0..e3b036dcdf00a 100644 --- a/codersdk/agentsdk/agentsdk.go +++ b/codersdk/agentsdk/agentsdk.go @@ -107,7 +107,7 @@ type Manifest struct { // 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. - OwnerUsername string `json:"owner_username"` + OwnerName string `json:"owner_name"` 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 f67ac63f3861b..2b7dff950a3e7 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, - OwnerUsername: manifest.OwnerUsername, + OwnerName: 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.OwnerUsername, + OwnerUsername: manifest.OwnerName, 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 dcafe3127a3df..09482b1694910 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", - OwnerUsername: "test-owner", + OwnerName: "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.OwnerUsername, back.OwnerUsername) + require.Equal(t, manifest.OwnerName, back.OwnerName) 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 ee762ddcd3d30..2c73d60a2696c 100644 --- a/codersdk/workspaces.go +++ b/codersdk/workspaces.go @@ -26,12 +26,12 @@ const ( // Workspace is a deployment of a template. It references a specific // version and can be updated. type Workspace struct { - ID uuid.UUID `json:"id" format:"uuid"` - 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,omitempty"` - OwnerUsername string `json:"owner_username"` + ID uuid.UUID `json:"id" format:"uuid"` + 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 is the username of the owner of the workspace. + OwnerName string `json:"owner_name"` OwnerAvatarURL string `json:"owner_avatar_url"` OrganizationID uuid.UUID `json:"organization_id" format:"uuid"` OrganizationName string `json:"organization_name"` @@ -50,7 +50,6 @@ type Workspace struct { AutostartSchedule *string `json:"autostart_schedule,omitempty"` TTLMillis *int64 `json:"ttl_ms,omitempty"` LastUsedAt time.Time `json:"last_used_at" format:"date-time"` - // DeletingAt indicates the time at which the workspace will be permanently deleted. // A workspace is eligible for deletion if it is dormant (a non-nil dormant_at value) // and a value has been specified for time_til_dormant_autodelete on its template. @@ -70,7 +69,7 @@ type Workspace struct { } func (w Workspace) FullName() string { - return fmt.Sprintf("%s/%s", w.OwnerUsername, w.Name) + return fmt.Sprintf("%s/%s", w.OwnerName, w.Name) } type WorkspaceHealth struct { diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index 99d1a7631ace1..65e3b5f7c8ec8 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -8433,7 +8433,6 @@ 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", @@ -8470,8 +8469,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | `outdated` | boolean | false | | | | `owner_avatar_url` | string | false | | | | `owner_id` | string | false | | | -| `owner_name` | string | false | | | -| `owner_username` | string | false | | | +| `owner_name` | string | false | | Owner name is the username of the owner of the workspace. | | `template_active_version_id` | string | false | | | | `template_allow_user_cancel_workspace_jobs` | boolean | false | | | | `template_display_name` | string | false | | | @@ -10138,7 +10136,6 @@ 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 6f3b2ec9ce76d..1e73787dfb77e 100644 --- a/docs/reference/api/workspaces.md +++ b/docs/reference/api/workspaces.md @@ -291,7 +291,6 @@ 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", @@ -577,7 +576,6 @@ 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", @@ -889,7 +887,6 @@ 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", @@ -1161,7 +1158,6 @@ 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", @@ -1448,7 +1444,6 @@ 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", @@ -1850,7 +1845,6 @@ 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 b1f7aad1d792f..61bc7f0e70c22 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_username, workspace.name), + workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name), updatedWorkspace, ); }, @@ -316,12 +316,12 @@ export const toggleFavorite = ( }, onSuccess: async () => { queryClient.setQueryData( - workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name), + workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name), { ...workspace, favorite: !workspace.favorite }, ); await queryClient.invalidateQueries({ queryKey: workspaceByOwnerAndNameKey( - workspace.owner_username, + workspace.owner_name, workspace.name, ), }); diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 25b91b3be5f64..8465f3d02be38 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -3278,8 +3278,7 @@ export interface Workspace { readonly created_at: string; readonly updated_at: string; readonly owner_id: string; - readonly owner_name?: string; - readonly owner_username: string; + readonly owner_name: 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 517bc047ee815..e61b214a25385 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_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`, + `/path-base/@${MockWorkspace.owner_name}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`, ); }); @@ -97,7 +97,7 @@ describe("getAppHref", () => { path: "", }); expect(href).toBe( - `/@${MockWorkspace.owner_username}/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la`, + `/@${MockWorkspace.owner_name}/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_username}/Test-Workspace.a-workspace-agent/apps/${app.slug}/`, + `/path-base/@${MockWorkspace.owner_name}/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 47e4447725481..d154b632dc1ca 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_username}/${workspace.name}.${ + return `/@${workspace.owner_name}/${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_username}/${workspace.name}.${ + return `${path}/@${workspace.owner_name}/${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 a3c3e02ac8d8a..4891c632bbc2a 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_username} + userName={workspace.owner_name} /> {wildcardHostname !== "" && container.ports.map((port) => { @@ -170,7 +170,7 @@ export const AgentDevcontainerCard: FC = ({ port.host_port, agent.name, workspace.name, - workspace.owner_username, + workspace.owner_name, location.protocol === "https" ? "https" : "http", ) : ""; diff --git a/site/src/modules/resources/AgentRow.tsx b/site/src/modules/resources/AgentRow.tsx index b8a80885eca62..a1db0e0390f3e 100644 --- a/site/src/modules/resources/AgentRow.tsx +++ b/site/src/modules/resources/AgentRow.tsx @@ -216,7 +216,7 @@ export const AgentRow: FC = ({ <> {showVSCode && ( = ({ )} diff --git a/site/src/modules/resources/PortForwardButton.tsx b/site/src/modules/resources/PortForwardButton.tsx index 2a3f5da93173c..e9ca8b6757973 100644 --- a/site/src/modules/resources/PortForwardButton.tsx +++ b/site/src/modules/resources/PortForwardButton.tsx @@ -287,7 +287,7 @@ export const PortForwardPopoverView: FC = ({ port, agent.name, workspace.name, - workspace.owner_username, + workspace.owner_name, listeningPortProtocol, ); window.open(url, "_blank"); @@ -328,7 +328,7 @@ export const PortForwardPopoverView: FC = ({ port.port, agent.name, workspace.name, - workspace.owner_username, + workspace.owner_name, listeningPortProtocol, ); const label = @@ -417,7 +417,7 @@ export const PortForwardPopoverView: FC = ({ share.port, agent.name, workspace.name, - workspace.owner_username, + workspace.owner_name, share.protocol, ); const label = share.port; diff --git a/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx b/site/src/modules/resources/VSCodeDesktopButton/VSCodeDesktopButton.stories.tsx index 792903da45e78..fe3f274b17d24 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_username, + userName: MockWorkspace.owner_name, 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 bd4b5b378760a..a16eb58ba72b3 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_username, + userName: MockWorkspace.owner_name, 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_username, + userName: MockWorkspace.owner_name, 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_username, + userName: MockWorkspace.owner_name, 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 8b02dd4930d62..22e9638ee7caa 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 8ebd5a048512b..db5d37e2b1007 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_username, + user: MockWorkspace.owner_name, }, MockWorkspace, ), diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx index 946cdf13a34b6..e5a18edbc2224 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_username}/${workspace.name}`); + navigate(`/@${workspace.owner_name}/${workspace.name}`); }, [navigate], ); diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx index 477420e41fa77..cf0e80d592cd6 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_username}/${workspace.name}`); + navigate(`/@${workspace.owner_name}/${workspace.name}`); }, [navigate], ); diff --git a/site/src/pages/TaskPage/TaskPage.tsx b/site/src/pages/TaskPage/TaskPage.tsx index 7a0b79d7a410a..d8b577892491d 100644 --- a/site/src/pages/TaskPage/TaskPage.tsx +++ b/site/src/pages/TaskPage/TaskPage.tsx @@ -126,7 +126,7 @@ const TaskPage = () => {
diff --git a/site/src/pages/TasksPage/TasksPage.tsx b/site/src/pages/TasksPage/TasksPage.tsx index 138c6d3322a18..3a98fc317a4ca 100644 --- a/site/src/pages/TasksPage/TasksPage.tsx +++ b/site/src/pages/TasksPage/TasksPage.tsx @@ -318,7 +318,7 @@ const TasksTable: FC = ({ templates }) => { {prompt} Access task @@ -341,7 +341,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 cda8437042c70..298f890637042 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_username, + MockWorkspace.owner_name, MockWorkspace.name, ), data: { @@ -54,7 +54,7 @@ const meta = { reactRouter: reactRouterParameters({ location: { pathParams: { - username: `@${MockWorkspace.owner_username}`, + username: `@${MockWorkspace.owner_name}`, workspace: MockWorkspace.name, }, }, diff --git a/site/src/pages/TerminalPage/TerminalPage.tsx b/site/src/pages/TerminalPage/TerminalPage.tsx index 4fd88556d7dbf..2023bdb0eeb29 100644 --- a/site/src/pages/TerminalPage/TerminalPage.tsx +++ b/site/src/pages/TerminalPage/TerminalPage.tsx @@ -332,7 +332,7 @@ const TerminalPage: FC = () => { {workspace.data ? pageTitle( - `Terminal · ${workspace.data.owner_username}/${workspace.data.name}`, + `Terminal · ${workspace.data.owner_name}/${workspace.data.name}`, ) : ""} diff --git a/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx b/site/src/pages/WorkspaceBuildPage/WorkspaceBuildPage.test.tsx index 20f79c0e389bc..f1f1edb54a5f7 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_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, + route: `/@${MockWorkspace.owner_name}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, path: "/:username/:workspace/builds/:buildNumber", }); await waitFor(() => expect(getWorkspaceBuildSpy).toBeCalledWith( - MockWorkspace.owner_username, + MockWorkspace.owner_name, MockWorkspace.name, MockWorkspaceBuild.build_number, ), @@ -52,7 +52,7 @@ describe("WorkspaceBuildPage", () => { client.onmessage = async () => { renderWithAuth(, { - route: `/@${MockWorkspace.owner_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}`, + route: `/@${MockWorkspace.owner_name}/${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_username}/${MockWorkspace.name}/builds/${MockWorkspace.latest_build.build_number}?${LOGS_TAB_KEY}=${MockWorkspaceAgent.id}`, + route: `/@${MockWorkspace.owner_name}/${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 a71e6636845ee..3f217a86a3aad 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_username}/${workspace.name}`, + route: `/@${workspace.owner_name}/${workspace.name}`, path: "/:username/:workspace", }); diff --git a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx index 363a5012c5765..7f12c70b8be54 100644 --- a/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx +++ b/site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx @@ -174,9 +174,7 @@ export const WorkspaceReadyPage: FC = ({ return ( <> - - {pageTitle(`${workspace.owner_username}/${workspace.name}`)} - + {pageTitle(`${workspace.owner_name}/${workspace.name}`)} { const { data: workspace } = useQuery( - workspaceByOwnerAndName(MockWorkspace.owner_username, MockWorkspace.name), + workspaceByOwnerAndName(MockWorkspace.owner_name, MockWorkspace.name), ); if (!workspace) { diff --git a/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx b/site/src/pages/WorkspacePage/WorkspaceScheduleControls.tsx index 4d117c39ee05a..5bced6f668d0f 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_username, workspace.name), + workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name), { ...workspace, latest_build: { diff --git a/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx b/site/src/pages/WorkspacePage/WorkspaceTopbar.tsx index 12d2f43f4fd04..943b967de92c6 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_username), + ...workspaceQuota(workspace.organization_name, workspace.owner_name), // 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 67fe21c9d57c2..6dac6536b5bfb 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_username}/${workspace.name}`); + navigate(`/${workspace.owner_name}/${workspace.name}`); }, }); diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceParametersPage/WorkspaceParametersPageExperimental.tsx index b0af993c3b921..781f8b12e8c67 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_username}/${workspace.name}`); + navigate(`/@${workspace.owner_name}/${workspace.name}`); }, }); @@ -208,7 +208,7 @@ const WorkspaceParametersPageExperimental: FC = () => { isSubmitting={updateParameters.isPending} onSubmit={handleSubmit} onCancel={() => - navigate(`/@${workspace.owner_username}/${workspace.name}`) + navigate(`/@${workspace.owner_name}/${workspace.name}`) } sendMessage={sendMessage} /> diff --git a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.stories.tsx index becc3dcd46b3b..3abb069f05d7b 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_username: MockUserMember.username, + owner_name: MockUserMember.username, }, { ...MockWorkspace, name: "Test-Workspace-3", last_used_at: "2023-11-16T15:29:10.302441433Z", owner_id: MockUserMember.id, - owner_username: MockUserMember.username, + owner_name: MockUserMember.username, }, ], }, diff --git a/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx b/site/src/pages/WorkspacesPage/BatchDeleteConfirmation.tsx index 655abfbce62f9..587cecf25efdd 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_username} + {workspace.owner_name} diff --git a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx index 6f05b025e3d45..140d433d3e860 100644 --- a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx +++ b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.stories.tsx @@ -16,7 +16,7 @@ import { type Update, } from "./BatchUpdateConfirmation"; -const workspaces = [ +const workspaces: Workspace[] = [ { ...MockRunningOutdatedWorkspace, id: "1" }, { ...MockDormantOutdatedWorkspace, id: "2" }, { ...MockOutdatedWorkspace, id: "3" }, @@ -26,7 +26,7 @@ const workspaces = [ ...MockRunningOutdatedWorkspace, id: "6", owner_id: MockUserMember.id, - owner_username: MockUserMember.username, + owner_name: MockUserMember.username, }, ]; diff --git a/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx b/site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx index e54a04a6ce8b4..a6b0a27b374f4 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_username} + {workspace.owner_name} diff --git a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx index d25170886db3f..bfb159ef81c86 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_username} + {workspace.owner_name}
} avatar={ } @@ -327,7 +327,7 @@ const WorkspacesRow: FC = ({ }) => { const navigate = useNavigate(); - const workspacePageLink = `/@${workspace.owner_username}/${workspace.name}`; + const workspacePageLink = `/@${workspace.owner_name}/${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_username, + owner: workspace.owner_name, 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_username, + owner: workspace.owner_name, 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_username, + username: workspace.owner_name, workspace: workspace.name, agent: agent.name, }); diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index e08199e4a4eb6..72db7f6644d30 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_username: MockUserOwner.username, + owner_name: MockUserOwner.username, owner_avatar_url: "https://avatars.githubusercontent.com/u/7122116?v=4", autostart_schedule: MockWorkspaceAutostartEnabled.schedule, ttl_ms: 2 * 60 * 60 * 1000,