8000 chore: cherry-pick bug fixes for release 2.23 by stirby · Pull Request #18219 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: cherry-pick bug fixes for release 2.23 #18219

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 5 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: handle workspace.agent and agent.workspace.owner in `coder s…
…sh` (#18093)

Closes #18088.

The linked issue is misleading -- `coder config-ssh` continues to support the `coder.` prefix. The reason the command
`ssh coder.workspace.agent` fails is because `coder ssh workspace.agent` wasn't supported. This PR fixes that.

We know we used to support `workspace.agent`, as this is what we recommend in the Web UI:
![image](https://github.com/user-attachments/assets/702bbbc7-c586-4947-98a6-4508a481280b)

This PR also adds support for `coder ssh agent.workspace.owner`, such that after running `coder config-ssh`, a command like
```
ssh agent.workspace.owner.coder
```
works, even without Coder Connect running. This is done for parity with an existing workflow that uses `ssh workspace.coder`, which either uses Coder Connect if available, or the CLI.

(cherry picked from commit da02375)
  • Loading branch information
ethanndickson authored and stirby committed Jun 3, 2025
commit 7bf0173e87c3202e773c48ad983aa25a8ec4b5fc
9 changes: 9 additions & 0 deletions cli/ssh.go
D50F
Original file line number Diff line number Diff line change
Expand Up @@ -1594,12 +1594,14 @@ func writeCoderConnectNetInfo(ctx context.Context, networkInfoDir string) error
// Converts workspace name input to owner/workspace.agent format
// Possible valid input formats:
// workspace
// workspace.agent
// owner/workspace
// owner--workspace
// owner/workspace--agent
// owner/workspace.agent
// owner--workspace--agent
// owner--workspace.agent
// agent.workspace.owner - for parity with Coder Connect
func normalizeWorkspaceInput(input string) string {
// Split on "/", "--", and "."
parts := workspaceNameRe.Split(input, -1)
Expand All @@ -1608,8 +1610,15 @@ func normalizeWorkspaceInput(input string) string {
case 1:
return input // "workspace"
case 2:
if strings.Contains(input, ".") {
return fmt.Sprintf("%s.%s", parts[0], parts[1]) // "workspace.agent"
}
return fmt.Sprintf("%s/%s", parts[0], parts[1]) // "owner/workspace"
case 3:
// If the only separator is a dot, it's the Coder Connect format
if !strings.Contains(input, "/") && !strings.Contains(input, "--") {
return fmt.Sprintf("%s/%s.%s", parts[2], parts[1], parts[0]) // "owner/workspace.agent"
}
return fmt.Sprintf("%s/%s.%s", parts[0], parts[1], parts[2]) // "owner/workspace.agent"
default:
return input // Fallback
Expand Down
2 changes: 2 additions & 0 deletions cli/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@ func TestSSH(t *testing.T) {

cases := []string{
"myworkspace",
"myworkspace.dev",
"myuser/myworkspace",
"myuser--myworkspace",
"myuser/myworkspace--dev",
"myuser/myworkspace.dev",
"myuser--myworkspace--dev",
"myuser--myworkspace.dev",
"dev.myworkspace.myuser",
}

for _, tc := range cases {
Expand Down
Loading
0