diff --git a/coder-sdk/workspace_providers.go b/coder-sdk/workspace_providers.go index 1ed0589c..5270389a 100644 --- a/coder-sdk/workspace_providers.go +++ b/coder-sdk/workspace_providers.go @@ -19,6 +19,7 @@ type KubernetesProvider struct { EnvproxyAccessURL string `json:"envproxy_access_url" table:"Access URL" validate:"required"` DevurlHost string `json:"devurl_host" table:"Devurl Host"` OrgWhitelist []string `json:"org_whitelist" table:"-"` + EnableNetV2 bool `json:"enable_net_v2" table:"Enable NetV2"` KubeProviderConfig `json:"config" table:"_"` } diff --git a/docs/coder_config-ssh.md b/docs/coder_config-ssh.md index c16d087b..1816b29a 100644 --- a/docs/coder_config-ssh.md +++ b/docs/coder_config-ssh.md @@ -15,7 +15,6 @@ coder config-ssh [flags] ``` --filepath string override the default path of your ssh config file (default "~/.ssh/config") -h, --help help for config-ssh - --next (alpha) uses coder tunnel to proxy ssh connection --remove remove the auto-generated Coder ssh config ``` diff --git a/internal/cmd/configssh.go b/internal/cmd/configssh.go index a482bbe7..bb0b39c9 100644 --- a/internal/cmd/configssh.go +++ b/internal/cmd/configssh.go @@ -35,23 +35,21 @@ func configSSHCmd() *cobra.Command { var ( configpath string remove = false - next = false ) cmd := &cobra.Command{ Use: "config-ssh", Short: "Configure SSH to access Coder workspaces", Long: "Inject the proper OpenSSH configuration into your local SSH config file.", - RunE: configSSH(&configpath, &remove, &next), + RunE: configSSH(&configpath, &remove), } cmd.Flags().StringVar(&configpath, "filepath", filepath.Join("~", ".ssh", "config"), "override the default path of your ssh config file") cmd.Flags().BoolVar(&remove, "remove", false, "remove the auto-generated Coder ssh config") - cmd.Flags().BoolVar(&next, "next", false, "(alpha) uses coder tunnel to proxy ssh connection") return cmd } -func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Command, _ []string) error { +func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []string) error { return func(cmd *cobra.Command, _ []string) error { ctx := cmd.Context() usr, err := user.Current() @@ -115,29 +113,12 @@ func configSSH(configpath *string, remove *bool, next *bool) func(cmd *cobra.Com return xerrors.New("SSH is disabled or not available for any workspaces in your Coder deployment.") } - wconf, err := client.SiteConfigWorkspaces(ctx) - if err != nil { - return xerrors.Errorf("getting site workspace config: %w", err) - } - p2p := false - if wconf.EnableP2P { - if *next { - p2p = true - } else { - fmt.Println("Note: NetworkingV2 is enabled on the coder deployment, use --next to enable it for ssh") - } - } else { - if *next { - return xerrors.New("NetworkingV2 feature is not enabled, cannot use --next flag") - } - } - binPath, err := os.Executable() if err != nil { return xerrors.Errorf("Failed to get executable path: %w", err) } - newConfig := makeNewConfigs(binPath, user.Username, workspacesWithProviders, privateKeyFilepath, p2p) + newConfig := makeNewConfigs(binPath, user.Username, workspacesWithProviders, privateKeyFilepath) err = os.MkdirAll(filepath.Dir(*configpath), os.ModePerm) if err != nil { @@ -198,7 +179,7 @@ func writeSSHKey(ctx context.Context, client coder.Client, privateKeyPath string return ioutil.WriteFile(privateKeyPath, []byte(key.PrivateKey), 0600) } -func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string, p2p bool) string { +func makeNewConfigs(binPath, userName string, workspaces []coderutil.WorkspaceWithWorkspaceProvider, privateKeyFilepath string) string { newConfig := fmt.Sprintf("\n%s\n%s\n\n", sshStartToken, sshStartMessage) 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 continue } - useTunnel := workspace.WorkspaceProvider.BuiltIn && p2p + useTunnel := workspace.WorkspaceProvider.SSHEnabled && workspace.WorkspaceProvider.EnableNetV2 newConfig += makeSSHConfig(binPath, u.Host, userName, workspace.Workspace.Name, privateKeyFilepath, useTunnel) } newConfig += fmt.Sprintf("\n%s\n", sshEndToken)