@@ -35,21 +35,23 @@ func configSSHCmd() *cobra.Command {
35
35
var (
36
36
configpath string
37
37
remove = false
38
+ next = false
38
39
)
39
40
40
41
cmd := & cobra.Command {
41
42
Use : "config-ssh" ,
42
43
Short : "Configure SSH to access Coder environments" ,
43
44
Long : "Inject the proper OpenSSH configuration into your local SSH config file." ,
44
- RunE : configSSH (& configpath , & remove ),
45
+ RunE : configSSH (& configpath , & remove , & next ),
45
46
}
46
47
cmd .Flags ().StringVar (& configpath , "filepath" , filepath .Join ("~" , ".ssh" , "config" ), "override the default path of your ssh config file" )
47
48
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" )
48
50
49
51
return cmd
50
52
}
51
53
52
- func configSSH (configpath * string , remove * bool ) func (cmd * cobra.Command , _ []string ) error {
54
+ func configSSH (configpath * string , remove * bool , next * bool ) func (cmd * cobra.Command , _ []string ) error {
53
55
return func (cmd * cobra.Command , _ []string ) error {
54
56
ctx := cmd .Context ()
55
57
usr , err := user .Current ()
@@ -117,8 +119,20 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
117
119
if err != nil {
118
120
return xerrors .Errorf ("getting site workspace config: %w" , err )
119
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
+ }
120
134
121
- newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , wconf . EnableP2P )
135
+ newConfig := makeNewConfigs (user .Username , envsWithProviders , privateKeyFilepath , p2p )
122
136
123
137
err = os .MkdirAll (filepath .Dir (* configpath ), os .ModePerm )
124
138
if err != nil {
0 commit comments