Skip to content

[pull] main from coder:main #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions cli/exp_scaletest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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-")
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions cli/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand All @@ -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,
)
Expand Down
16 changes: 8 additions & 8 deletions cli/open_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions cli/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
58 changes: 29 additions & 29 deletions cli/schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down Expand Up @@ -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))
})
Expand All @@ -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) {
Expand All @@ -150,22 +150,22 @@ 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)
require.NoError(t, inv.Run())

// 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))
})
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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"])
Expand All @@ -272,61 +272,61 @@ 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)
pty := ptytest.New(t).Attach(inv)
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))
})

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)
pty := ptytest.New(t).Attach(inv)
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))
})

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)
pty := ptytest.New(t).Attach(inv)
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)
pty := ptytest.New(t).Attach(inv)
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)
})
}

Expand Down Expand Up @@ -359,15 +359,15 @@ 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)
pty := ptytest.New(t).Attach(inv)
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")
Expand Down
4 changes: 2 additions & 2 deletions cli/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand Down
Loading
Loading