Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit edc273f

Browse files
authored
chore: Remove usage of netv2 flag for config-ssh (#407)
* chore: Remove usage of netv2 flag for config-ssh * Remove access URL * Remove username * Remove username from caller * Remove username
1 parent 8da2581 commit edc273f

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

coder-sdk/workspace_providers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type KubernetesProvider struct {
1919
EnvproxyAccessURL string `json:"envproxy_access_url" table:"Access URL" validate:"required"`
2020
DevurlHost string `json:"devurl_host" table:"Devurl Host"`
2121
OrgWhitelist []string `json:"org_whitelist" table:"-"`
22-
EnableNetV2 bool `json:"enable_net_v2" table:"Enable NetV2"`
2322
KubeProviderConfig `json:"config" table:"_"`
2423
}
2524

internal/cmd/configssh.go

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"io/ioutil"
7-
"net/url"
87
"os"
98
"os/user"
109
"path/filepath"
@@ -119,7 +118,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
119118
return xerrors.Errorf("Failed to get executable path: %w", err)
120119
}
121120

122-
newConfig := makeNewConfigs(binPath, user.Username, workspacesWithProviders, privateKeyFilepath)
121+
newConfig := makeNewConfigs(binPath, workspacesWithProviders, privateKeyFilepath)
123122

124123
err = os.MkdirAll(filepath.Dir(*configpath), os.ModePerm)
125124
if err != nil {
@@ -227,7 +226,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
227226
return ioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey), 0600)
228227
}
229228

230-
func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string) string {
229+
func makeNewConfigs(binPath string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string) string {
231230
newConfig := fmt.Sprintf("\n%s\n%s\n\n", sshStartToken, sshStartMessage)
232231

233232
sort.Slice(workspaces, func(i, j int) bool { return workspaces[i].Workspace.Name < workspaces[j].Workspace.Name })
@@ -240,24 +239,17 @@ func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWi
240239
)
241240
continue
242241
}
243-
u, err := url.Parse(workspace.WorkspaceProvider.EnvproxyAccessURL)
244-
if err != nil {
245-
clog.LogWarn("invalid access url", clog.Causef("malformed url: %q", workspace.WorkspaceProvider.EnvproxyAccessURL))
246-
continue
247-
}
248242

249-
useTunnel := workspace.WorkspaceProvider.SSHEnabled && workspace.WorkspaceProvider.EnableNetV2
250-
newConfig += makeSSHConfig(binPath, u.Host, userName, workspace.Workspace.Name, privateKeyFilepath, useTunnel)
243+
newConfig += makeSSHConfig(binPath, workspace.Workspace.Name, privateKeyFilepath)
251244
}
252245
newConfig += fmt.Sprintf("\n%s\n", sshEndToken)
253246

254247
return newConfig
255248
}
256249

257-
func makeSSHConfig(binPath, host, userName, workspaceName, privateKeyFilepath string, tunnel bool) string {
258-
if tunnel {
259-
host := fmt.Sprintf(
260-
`Host coder.%s
250+
func makeSSHConfig(binPath, workspaceName, privateKeyFilepath string) string {
251+
entry := fmt.Sprintf(
252+
`Host coder.%s
261253
HostName coder.%s
262254
ProxyCommand "%s" tunnel %s 12213 stdio
263255
StrictHostKeyChecking no
@@ -266,25 +258,14 @@ func makeSSHConfig(binPath, host, userName, workspaceName, privateKeyFilepath st
266258
IdentityFile="%s"
267259
`, workspaceName, workspaceName, binPath, workspaceName, privateKeyFilepath)
268260

269-
if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
270-
host += ` ControlMaster auto
261+
if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
262+
entry += ` ControlMaster auto
271263
ControlPath ~/.ssh/.connection-%r@%h:%p
272264
ControlPersist 600
273265
`
274-
}
275-
276-
return host
277266
}
278267

279-
return fmt.Sprintf(
280-
`Host coder.%s
281-
HostName %s
282-
User %s-%s
283-
StrictHostKeyChecking no
284-
ConnectTimeout=0
285-
IdentitiesOnly yes
286-
IdentityFile="%s"
287-
`, workspaceName, host, userName, workspaceName, privateKeyFilepath)
268+
return entry
288269
}
289270

290271
func writeStr(filename, data string) error {

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