Skip to content
Open
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
18 changes: 0 additions & 18 deletions pkg/cmd/refresh/sshaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ func resolveWorkspaceSSH(
workspace.SSHPort = int(port.GetPortNumber())
workspace.SSHUser = access.GetLinuxUser()
workspace.SSHProxyHostname = ""

// To support the "--host" fallback, preserve the legacy hostname information returned by the initial workspace query.
if providerHostname := providerSSHHostname(environment.GetInstance(), port.GetHostname()); providerHostname != "" {
workspace.HostSSHHostname = providerHostname
workspace.HostSSHProxyHostname = ""
}
return workspace, nil
}

Expand All @@ -145,15 +139,3 @@ func findNetworkPort(networkInfo *devplanev1.EnvironmentNetworkInfo, portID stri
}
return nil
}

func providerSSHHostname(instance *devplanev1.Instance, workloadHostname string) string {
if instance == nil {
return ""
}
for _, hostname := range []string{instance.GetPublicIp(), instance.GetPublicDns(), instance.GetHostname()} {
if hostname != "" && hostname != workloadHostname {
return hostname
}
}
return ""
}
7 changes: 3 additions & 4 deletions pkg/cmd/refresh/sshaccess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *stubEnvironmentSSHClient) GetNetworkInfo(
}), nil
}

func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) {
func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPortWithoutChangingHostRoute(t *testing.T) {
workspace := entity.Workspace{
ID: "env-1",
Name: "container-env",
Expand All @@ -50,7 +50,8 @@ func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) {
SSHUser: "ubuntu",
SSHPort: 22,
HostSSHUser: "ubuntu",
HostSSHPort: 22,
HostSSHPort: 41235,
HostSSHHostname: "host-gateway.example.com",
SSHProxyHostname: "legacy-proxy.example.com",
HostSSHProxyHostname: "legacy-host-proxy.example.com",
}
Expand Down Expand Up @@ -80,8 +81,6 @@ func TestEnrichWorkspacesWithSSHAccess_UsesCurrentUsersPort(t *testing.T) {
want.SSHPort = 41234
want.SSHUser = "root"
want.SSHProxyHostname = ""
want.HostSSHHostname = "203.0.113.10"
want.HostSSHProxyHostname = ""

if diff := cmp.Diff([]entity.Workspace{want}, got); diff != "" {
t.Fatalf("unexpected workspace (-want +got): %s", diff)
Expand Down
Loading