@@ -12,7 +12,7 @@ import { StaticHttpProvider } from "./app/static"
12
12
import { UpdateHttpProvider } from "./app/update"
13
13
import { VscodeHttpProvider } from "./app/vscode"
14
14
import { Args , bindAddrFromAllSources , optionDescriptions , parse , readConfigFile , setDefaults } from "./cli"
15
- import { coderCloudExpose , coderCloudProxy } from "./coder-cloud"
15
+ import { coderCloudLink , coderCloudProxy } from "./coder-cloud"
16
16
import { AuthType , HttpServer , HttpServerOptions } from "./http"
17
17
import { loadPlugins } from "./plugin"
18
18
import { generateCertificate , hash , humanPath , open } from "./util"
@@ -36,6 +36,15 @@ const version = pkg.version || "development"
36
36
const commit = pkg . commit || "development"
37
37
38
38
const main = async ( args : Args , cliArgs : Args , configArgs : Args ) : Promise < void > => {
39
+ if ( args [ "coder-link" ] ) {
40
+ // If we're being exposed to the cloud, we listen on a random address.
41
+ args = {
42
+ ...args ,
43
+ host : "localhost" ,
44
+ port : 0 ,
45
+ }
46
+ }
47
+
39
48
if ( ! args . auth ) {
40
49
args = {
41
50
...args ,
@@ -131,6 +140,22 @@ const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise<void>
131
140
await open ( openAddress ) . catch ( console . error )
132
141
logger . info ( `Opened ${ openAddress } ` )
133
142
}
143
+
144
+ if ( args [ "coder-link" ] ) {
145
+ if ( ! args [ "coder-link" ] . value ) {
146
+ logger . error ( "You must pass a name to link with coder cloud. See --help" )
147
+ process . exit ( 1 )
148
+ }
149
+
150
+ logger . info ( `linking code-server to the cloud with name ${ args [ "coder-link" ] . value } ` )
151
+
152
+ try {
153
+ await coderCloudLink ( args [ "coder-link" ] . value )
154
+ } catch ( err ) {
155
+ logger . error ( err . message )
156
+ process . exit ( 1 )
157
+ }
158
+ }
134
159
}
135
160
136
161
async function entry ( ) : Promise < void > {
@@ -191,20 +216,6 @@ async function entry(): Promise<void> {
191
216
process . exit ( 1 )
192
217
} )
193
218
vscode . on ( "exit" , ( code ) => process . exit ( code || 0 ) )
194
- } else if ( args [ "expose" ] ) {
195
- logger . debug ( "exposing code-server via the coder-cloud agent" )
196
-
197
- if ( ! args [ "expose" ] . value ) {
198
- logger . error ( "You must pass a name to expose with coder cloud. See --help" )
199
- process . exit ( 1 )
200
- }
201
-
202
- try {
203
- await coderCloudExpose ( args [ "expose" ] . value )
204
- } catch ( err ) {
205
- logger . error ( err . message )
206
- process . exit ( 1 )
207
- }
208
219
} else if ( process . env . VSCODE_IPC_HOOK_CLI ) {
209
220
const pipeArgs : OpenCommandPipeArgs = {
210
221
type : "open" ,
0 commit comments