chore: make owner_name and owner_username consistent (#18081)

We've been using owner_name inconsistently as username. So this PR fixes
it by making the attribute naming more consistent.
This commit is contained in:
Bruno Quaresma
2025-05-28 17:25:32 -03:00
committed by GitHub
parent 3a2e36237d
commit 2ec7404197
53 changed files with 151 additions and 131 deletions
+1 -1
View File
@@ -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)
}
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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,
+4 -4
View File
@@ -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,
)
+8 -8
View File
@@ -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",
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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,
+29 -29
View File
@@ -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")
+2 -2
View File
@@ -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.
+5 -5
View File
@@ -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) {
+4 -4
View File
@@ -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)
+1 -1
View File
@@ -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",
+3
View File
@@ -17004,6 +17004,9 @@ const docTemplate = `{
"owner_name": {
"type": "string"
},
"owner_username": {
"type": "string"
},
"template_active_version_id": {
"type": "string",
"format": "uuid"
+3
View File
@@ -15509,6 +15509,9 @@
"owner_name": {
"type": "string"
},
"owner_username": {
"type": "string"
},
"template_active_version_id": {
"type": "string",
"format": "uuid"
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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)
+2 -1
View File
@@ -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,
+6 -6
View File
@@ -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)
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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)
+3 -2
View File
@@ -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 {
+3
View File
@@ -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",
+6
View File
@@ -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",
+3 -3
View File
@@ -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,
),
});
+2 -1
View File
@@ -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;
+3 -3
View File
@@ -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}/`,
);
});
});
+2 -2
View File
@@ -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)}/`;
};
@@ -142,7 +142,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
<div className="flex gap-4 flex-wrap mt-4">
<VSCodeDevContainerButton
userName={workspace.owner_name}
userName={workspace.owner_username}
workspaceName={workspace.name}
devContainerName={container.name}
devContainerFolder={containerFolder}
@@ -154,7 +154,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
workspaceName={workspace.name}
agentName={agent.name}
containerName={container.name}
userName={workspace.owner_name}
userName={workspace.owner_username}
/>
{wildcardHostname !== "" &&
container.ports.map((port) => {
@@ -170,7 +170,7 @@ export const AgentDevcontainerCard: FC<AgentDevcontainerCardProps> = ({
port.host_port,
agent.name,
workspace.name,
workspace.owner_name,
workspace.owner_username,
location.protocol === "https" ? "https" : "http",
)
: "";
+3 -3
View File
@@ -216,7 +216,7 @@ export const AgentRow: FC<AgentRowProps> = ({
host={proxy.preferredWildcardHostname}
workspaceName={workspace.name}
agent={agent}
username={workspace.owner_name}
username={workspace.owner_username}
workspaceID={workspace.id}
template={template}
/>
@@ -239,7 +239,7 @@ export const AgentRow: FC<AgentRowProps> = ({
<>
{showVSCode && (
<VSCodeDesktopButton
userName={workspace.owner_name}
userName={workspace.owner_username}
workspaceName={workspace.name}
agentName={agent.name}
folderPath={agent.expanded_directory}
@@ -261,7 +261,7 @@ export const AgentRow: FC<AgentRowProps> = ({
<TerminalLink
workspaceName={workspace.name}
agentName={agent.name}
userName={workspace.owner_name}
userName={workspace.owner_username}
/>
)}
</section>
@@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDesktopButton>;
export const Default: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
displayApps: [
@@ -12,7 +12,7 @@ type Story = StoryObj<typeof VSCodeDevContainerButton>;
export const Default: Story = {
args: {
userName: MockWorkspace.owner_name,
userName: MockWorkspace.owner_username,
workspaceName: MockWorkspace.name,
agentName: MockWorkspaceAgent.name,
devContainerName: "musing_ride",
@@ -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",
@@ -90,7 +90,7 @@ export const WorkspaceMoreActions: FC<WorkspaceMoreActionsProps> = ({
<DropdownMenuContent id="workspace-options" align="end">
<DropdownMenuItem asChild>
<RouterLink
to={`/@${workspace.owner_name}/${workspace.name}/settings`}
to={`/@${workspace.owner_username}/${workspace.name}/settings`}
>
<SettingsIcon />
Settings
@@ -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,
),
@@ -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],
);
@@ -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],
);
+1 -1
View File
@@ -341,7 +341,7 @@ const TasksTable: FC<TasksTableProps> = ({ templates }) => {
</TableCell>
<TableCell>
<AvatarData
title={workspace.owner_name}
title={workspace.owner_username}
subtitle={
<span className="block first-letter:uppercase">
{relativeTime(new Date(workspace.created_at))}
@@ -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,
},
},
+1 -1
View File
@@ -332,7 +332,7 @@ const TerminalPage: FC = () => {
<title>
{workspace.data
? pageTitle(
`Terminal · ${workspace.data.owner_name}/${workspace.data.name}`,
`Terminal · ${workspace.data.owner_username}/${workspace.data.name}`,
)
: ""}
</title>
@@ -21,12 +21,12 @@ describe("WorkspaceBuildPage", () => {
.spyOn(API, "getWorkspaceBuildByNumber")
.mockResolvedValue(MockWorkspaceBuild);
renderWithAuth(<WorkspaceBuildPage />, {
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(<WorkspaceBuildPage />, {
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(<WorkspaceBuildPage />, {
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}`);
@@ -54,7 +54,7 @@ const renderWorkspacePage = async (
renderWithAuth(<WorkspacePage />, {
...options,
route: `/@${workspace.owner_name}/${workspace.name}`,
route: `/@${workspace.owner_username}/${workspace.name}`,
path: "/:username/:workspace",
});
@@ -184,7 +184,9 @@ export const WorkspaceReadyPage: FC<WorkspaceReadyPageProps> = ({
return (
<>
<Helmet>
<title>{pageTitle(`${workspace.owner_name}/${workspace.name}`)}</title>
<title>
{pageTitle(`${workspace.owner_username}/${workspace.name}`)}
</title>
<link
rel="alternate icon"
type="image/png"
@@ -13,7 +13,7 @@ import { WorkspaceScheduleControls } from "./WorkspaceScheduleControls";
const Wrapper: FC = () => {
const { data: workspace } = useQuery(
workspaceByOwnerAndName(MockWorkspace.owner_name, MockWorkspace.name),
workspaceByOwnerAndName(MockWorkspace.owner_username, MockWorkspace.name),
);
if (!workspace) {
@@ -123,7 +123,7 @@ const AutostopDisplay: FC<AutostopDisplayProps> = ({
const updateWorkspaceDeadlineQueryData = (deadline: Dayjs) => {
queryClient.setQueryData(
workspaceByOwnerAndNameKey(workspace.owner_name, workspace.name),
workspaceByOwnerAndNameKey(workspace.owner_username, workspace.name),
{
...workspace,
latest_build: {
@@ -73,7 +73,7 @@ export const WorkspaceTopbar: FC<WorkspaceProps> = ({
// 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<WorkspaceProps> = ({
<div css={styles.topbarLeft}>
<TopbarData>
<OwnerBreadcrumb
ownerName={workspace.owner_name}
ownerName={workspace.owner_username}
ownerAvatarUrl={workspace.owner_avatar_url}
/>
@@ -39,7 +39,7 @@ const WorkspaceParametersPage: FC = () => {
rich_parameter_values: buildParameters,
}),
onSuccess: () => {
navigate(`/${workspace.owner_name}/${workspace.name}`);
navigate(`/${workspace.owner_username}/${workspace.name}`);
},
});
@@ -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}
/>
@@ -19,14 +19,14 @@ const meta: Meta<typeof BatchDeleteConfirmation> = {
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,
},
],
},
@@ -174,7 +174,7 @@ const Workspaces: FC<StageProps> = ({ workspaces }) => {
<span
css={{ whiteSpace: "nowrap", textOverflow: "ellipsis" }}
>
{workspace.owner_name}
{workspace.owner_username}
</span>
<PersonIcon />
</Stack>
@@ -26,7 +26,7 @@ const workspaces = [
...MockRunningOutdatedWorkspace,
id: "6",
owner_id: MockUserMember.id,
owner_name: MockUserMember.username,
owner_username: MockUserMember.username,
},
];
@@ -287,7 +287,7 @@ const DormantWorkspaces: FC<DormantWorkspacesProps> = ({ workspaces }) => {
<span
css={{ whiteSpace: "nowrap", textOverflow: "ellipsis" }}
>
{workspace.owner_name}
{workspace.owner_username}
</span>
</Stack>
<Stack direction="row" alignItems="center" spacing={1}>
@@ -253,13 +253,13 @@ export const WorkspacesTable: FC<WorkspacesTableProps> = ({
subtitle={
<div>
<span className="sr-only">Owner: </span>
{workspace.owner_name}
{workspace.owner_username}
</div>
}
avatar={
<Avatar
src={workspace.owner_avatar_url}
fallback={workspace.owner_name}
fallback={workspace.owner_username}
size="lg"
/>
}
@@ -327,7 +327,7 @@ const WorkspacesRow: FC<WorkspacesRowProps> = ({
}) => {
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<WorkspaceAppsProps> = ({ 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<WorkspaceAppsProps> = ({ 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<WorkspaceAppsProps> = ({ workspace }) => {
if (builtinApps.has("web_terminal")) {
const href = getTerminalHref({
username: workspace.owner_name,
username: workspace.owner_username,
workspace: workspace.name,
agent: agent.name,
});
+1 -1
View File
@@ -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,