Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitedc273f

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 parent8da2581 commitedc273f

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
EnvproxyAccessURLstring`json:"envproxy_access_url" table:"Access URL" validate:"required"`
2020
DevurlHoststring`json:"devurl_host" table:"Devurl Host"`
2121
OrgWhitelist []string`json:"org_whitelist" table:"-"`
22-
EnableNetV2bool`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
returnxerrors.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
iferr!=nil {
@@ -227,7 +226,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
227226
returnioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey),0600)
228227
}
229228

230-
funcmakeNewConfigs(binPath,userNamestring,workspaces []coderutil.WorkspaceWithWorkspaceProvider,privateKeyFilepathstring)string {
229+
funcmakeNewConfigs(binPathstring,workspaces []coderutil.WorkspaceWithWorkspaceProvider,privateKeyFilepathstring)string {
231230
newConfig:=fmt.Sprintf("\n%s\n%s\n\n",sshStartToken,sshStartMessage)
232231

233232
sort.Slice(workspaces,func(i,jint)bool {returnworkspaces[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-
iferr!=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
returnnewConfig
255248
}
256249

257-
funcmakeSSHConfig(binPath,host,userName,workspaceName,privateKeyFilepathstring,tunnelbool)string {
258-
iftunnel {
259-
host:=fmt.Sprintf(
260-
`Host coder.%s
250+
funcmakeSSHConfig(binPath,workspaceName,privateKeyFilepathstring)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-
ifruntime.GOOS=="linux"||runtime.GOOS=="darwin" {
270-
host+=` ControlMaster auto
261+
ifruntime.GOOS=="linux"||runtime.GOOS=="darwin" {
262+
entry+=` ControlMaster auto
271263
ControlPath ~/.ssh/.connection-%r@%h:%p
272264
ControlPersist 600
273265
`
274-
}
275-
276-
returnhost
277266
}
278267

279-
returnfmt.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+
returnentry
288269
}
289270

290271
funcwriteStr(filename,datastring)error {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp