Skip to content

Commit a9b1ccd

Browse files
fix: handle workspace.agent and agent.workspace.owner in coder ssh (cherry-pick #18093) (#18096)
Co-authored-by: Ethan <39577870+ethanndickson@users.noreply.github.com> Closes #18088.
1 parent 4fe7ee2 commit a9b1ccd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cli/ssh.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,12 +1569,14 @@ func writeCoderConnectNetInfo(ctx context.Context, networkInfoDir string) error
15691569
// Converts workspace name input to owner/workspace.agent format
15701570
// Possible valid input formats:
15711571
// workspace
1572+
// workspace.agent
15721573
// owner/workspace
15731574
// owner--workspace
15741575
// owner/workspace--agent
15751576
// owner/workspace.agent
15761577
// owner--workspace--agent
15771578
// owner--workspace.agent
1579+
// agent.workspace.owner - for parity with Coder Connect
15781580
func normalizeWorkspaceInput(input string) string {
15791581
// Split on "/", "--", and "."
15801582
parts := workspaceNameRe.Split(input, -1)
@@ -1583,8 +1585,15 @@ func normalizeWorkspaceInput(input string) string {
15831585
case 1:
15841586
return input // "workspace"
15851587
case 2:
1588+
if strings.Contains(input, ".") {
1589+
return fmt.Sprintf("%s.%s", parts[0], parts[1]) // "workspace.agent"
1590+
}
15861591
return fmt.Sprintf("%s/%s", parts[0], parts[1]) // "owner/workspace"
15871592
case 3:
1593+
// If the only separator is a dot, it's the Coder Connect format
1594+
if !strings.Contains(input, "/") && !strings.Contains(input, "--") {
1595+
return fmt.Sprintf("%s/%s.%s", parts[2], parts[1], parts[0]) // "owner/workspace.agent"
1596+
}
15881597
return fmt.Sprintf("%s/%s.%s", parts[0], parts[1], parts[2]) // "owner/workspace.agent"
15891598
default:
15901599
return input // Fallback

cli/ssh_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ func TestSSH(t *testing.T) {
107107

108108
cases := []string{
109109
"myworkspace",
110+
"myworkspace.dev",
110111
"myuser/myworkspace",
111112
"myuser--myworkspace",
112113
"myuser/myworkspace--dev",
113114
"myuser/myworkspace.dev",
114115
"myuser--myworkspace--dev",
115116
"myuser--myworkspace.dev",
117+
"dev.myworkspace.myuser",
116118
}
117119

118120
for _, tc := range cases {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy