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

Commit 1ed07d2

Browse files
authored
[ch-13671] stop using global enable_netv2 in favor of workspace provider config (#370)
* stop using global enable_netv2 in favor of workspace provider config * gendocs
1 parent cdbfc48 commit 1ed07d2

File tree

3 files changed

+6
-25
lines changed

3 files changed

+6
-25
lines changed

coder-sdk/workspace_providers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ 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"`
2223
KubeProviderConfig `json:"config" table:"_"`
2324
}
2425

docs/coder_config-ssh.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ coder config-ssh [flags]
1515
```
1616
--filepath string override the default path of your ssh config file (default "~/.ssh/config")
1717
-h, --help help for config-ssh
18-
--next (alpha) uses coder tunnel to proxy ssh connection
1918
--remove remove the auto-generated Coder ssh config
2019
```
2120

internal/cmd/configssh.go

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,21 @@ func configSSHCmd() *cobra.Command {
3535
var (
3636
configpath string
3737
remove = false
38-
next = false
3938
)
4039

4140
cmd := &cobra.Command{
4241
Use: "config-ssh",
4342
Short: "Configure SSH to access Coder workspaces",
4443
Long: "Inject the proper OpenSSH configuration into your local SSH config file.",
45-
RunE: configSSH(&configpath, &remove, &next),
44+
RunE: configSSH(&configpath, &remove),
4645
}
4746
cmd.Flags().StringVar(&configpath, "filepath", filepath.Join("~", ".ssh", "config"), "override the default path of your ssh config file")
4847
cmd.Flags().BoolVar(&remove, "remove", false, "remove the auto-generated Coder ssh config")
49-
cmd.Flags().BoolVar(&next, "next", false, "(alpha) uses coder tunnel to proxy ssh connection")
5048

5149
return cmd
5250
}
5351

54-
func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Command, _ []string) error {
52+
func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []string) error {
5553
return func(cmd *cobra.Command, _ []string) error {
5654
ctx := cmd.Context()
5755
usr, err := user.Current()
@@ -115,29 +113,12 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com
115113
return xerrors.New("SSH is disabled or not available for any workspaces in your Coder deployment.")
116114
}
117115

118-
wconf, err := client.SiteConfigWorkspaces(ctx)
119-
if err != nil {
120-
return xerrors.Errorf("getting site workspace config: %w", err)
121-
}
122-
p2p := false
123-
if wconf.EnableP2P {
124-
if *next {
125-
p2p = true
126-
} else {
127-
fmt.Println("Note: NetworkingV2 is enabled on the coder deployment, use --next to enable it for ssh")
128-
}
129-
} else {
130-
if *next {
131-
return xerrors.New("NetworkingV2 feature is not enabled, cannot use --next flag")
132-
}
133-
}
134-
135116
binPath, err := os.Executable()
136117
if err != nil {
137118
return xerrors.Errorf("Failed to get executable path: %w", err)
138119
}
139120

140-
newConfig := makeNewConfigs(binPath, user.Username, workspacesWithProviders, privateKeyFilepath, p2p)
121+
newConfig := makeNewConfigs(binPath, user.Username, workspacesWithProviders, privateKeyFilepath)
141122

142123
err = os.MkdirAll(filepath.Dir(*configpath), os.ModePerm)
143124
if err != nil {
@@ -198,7 +179,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string
198179
return ioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey), 0600)
199180
}
200181

201-
func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string, p2p bool) string {
182+
func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string) string {
202183
newConfig := fmt.Sprintf("\n%s\n%s\n\n", sshStartToken, sshStartMessage)
203184

204185
sort.Slice(workspaces, func(i, j int) bool { return workspaces[i].Workspace.Name < workspaces[j].Workspace.Name })
@@ -217,7 +198,7 @@ func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWi
217198
continue
218199
}
219200

220-
useTunnel := workspace.WorkspaceProvider.BuiltIn && p2p
201+
useTunnel := workspace.WorkspaceProvider.SSHEnabled && workspace.WorkspaceProvider.EnableNetV2
221202
newConfig += makeSSHConfig(binPath, u.Host, userName, workspace.Workspace.Name, privateKeyFilepath, useTunnel)
222203
}
223204
newConfig += fmt.Sprintf("\n%s\n", sshEndToken)

0 commit comments

Comments
 (0)