@@ -7,13 +7,13 @@ import { errToStr } from "./api/api-helper";
7
7
import { CoderApi } from "./api/coderApi" ;
8
8
import { needToken } from "./api/utils" ;
9
9
import { Commands } from "./commands" ;
10
+ import { BinaryManager } from "./core/binaryManager" ;
10
11
import { CliConfigManager } from "./core/cliConfig" ;
11
12
import { MementoManager } from "./core/mementoManager" ;
12
13
import { PathResolver } from "./core/pathResolver" ;
13
14
import { SecretsManager } from "./core/secretsManager" ;
14
15
import { CertificateError , getErrorDetail } from "./error" ;
15
16
import { Remote } from "./remote" ;
16
- import { Storage } from "./storage" ;
17
17
import { toSafeHost } from "./util" ;
18
18
import { WorkspaceQuery , WorkspaceProvider } from "./workspacesProvider" ;
19
19
@@ -62,7 +62,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
62
62
const secretsManager = new SecretsManager ( ctx . secrets ) ;
63
63
64
64
const output = vscode . window . createOutputChannel ( "Coder" , { log : true } ) ;
65
- const storage = new Storage ( output , pathResolver ) ;
66
65
67
66
// Try to clear this flag ASAP
68
67
const isFirstConnect = await mementoManager . getAndClearFirstConnect ( ) ;
@@ -74,20 +73,20 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
74
73
const client = CoderApi . create (
75
74
url || "" ,
76
75
await secretsManager . getSessionToken ( ) ,
77
- storage . output ,
76
+ output ,
78
77
( ) => vscode . workspace . getConfiguration ( ) ,
79
78
) ;
80
79
81
80
const myWorkspacesProvider = new WorkspaceProvider (
82
81
WorkspaceQuery . Mine ,
83
82
client ,
84
- storage ,
83
+ output ,
85
84
5 ,
86
85
) ;
87
86
const allWorkspacesProvider = new WorkspaceProvider (
88
87
WorkspaceQuery . All ,
89
88
client ,
90
- storage ,
89
+ output ,
91
90
) ;
92
91
93
92
// createTreeView, unlike registerTreeDataProvider, gives us the tree view API
@@ -257,15 +256,18 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
257
256
} ,
258
257
} ) ;
259
258
259
+ const binaryManager = new BinaryManager ( output , pathResolver ) ;
260
+
260
261
// Register globally available commands. Many of these have visibility
261
262
// controlled by contexts, see `when` in the package.json.
262
263
const commands = new Commands (
263
264
vscodeProposed ,
264
265
client ,
265
- storage ,
266
+ output ,
266
267
pathResolver ,
267
268
mementoManager ,
268
269
secretsManager ,
270
+ binaryManager ,
269
271
) ;
270
272
vscode . commands . registerCommand ( "coder.login" , commands . login . bind ( commands ) ) ;
271
273
vscode . commands . registerCommand (
@@ -322,10 +324,11 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
322
324
if ( remoteSSHExtension && vscodeProposed . env . remoteAuthority ) {
323
325
const remote = new Remote (
324
326
vscodeProposed ,
325
- storage ,
327
+ output ,
326
328
commands ,
327
329
ctx . extensionMode ,
328
330
pathResolver ,
331
+ binaryManager ,
329
332
) ;
330
333
try {
331
334
const details = await remote . setup (
@@ -340,7 +343,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
340
343
}
341
344
} catch ( ex ) {
342
345
if ( ex instanceof CertificateError ) {
343
- storage . output . warn ( ex . x509Err || ex . message ) ;
346
+ output . warn ( ex . x509Err || ex . message ) ;
344
347
await ex . showModal ( "Failed to open workspace" ) ;
345
348
} else if ( isAxiosError ( ex ) ) {
346
349
const msg = getErrorMessage ( ex , "None" ) ;
@@ -349,7 +352,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
349
352
const method = ex . config ?. method ?. toUpperCase ( ) || "request" ;
350
353
const status = ex . response ?. status || "None" ;
351
354
const message = `API ${ method } to '${ urlString } ' failed.\nStatus code: ${ status } \nMessage: ${ msg } \nDetail: ${ detail } ` ;
352
- storage . output . warn ( message ) ;
355
+ output . warn ( message ) ;
353
356
await vscodeProposed . window . showErrorMessage (
354
357
"Failed to open workspace" ,
355
358
{
@@ -360,7 +363,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
360
363
) ;
361
364
} else {
362
365
const message = errToStr ( ex , "No error message was provided" ) ;
363
- storage . output . warn ( message ) ;
366
+ output . warn ( message ) ;
364
367
await vscodeProposed . window . showErrorMessage (
365
368
"Failed to open workspace" ,
366
369
{
@@ -379,12 +382,12 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
379
382
// See if the plugin client is authenticated.
380
383
const baseUrl = client . getAxiosInstance ( ) . defaults . baseURL ;
381
384
if ( baseUrl ) {
382
- storage . output . info ( `Logged in to ${ baseUrl } ; checking credentials` ) ;
385
+ output . info ( `Logged in to ${ baseUrl } ; checking credentials` ) ;
383
386
client
384
387
. getAuthenticatedUser ( )
385
388
. then ( async ( user ) => {
386
389
if ( user && user . roles ) {
387
- storage . output . info ( "Credentials are valid" ) ;
390
+ output . info ( "Credentials are valid" ) ;
388
391
vscode . commands . executeCommand (
389
392
"setContext" ,
390
393
"coder.authenticated" ,
@@ -402,13 +405,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
402
405
myWorkspacesProvider . fetchAndRefresh ( ) ;
403
406
allWorkspacesProvider . fetchAndRefresh ( ) ;
404
407
} else {
405
- storage . output . warn ( "No error, but got unexpected response" , user ) ;
408
+ output . warn ( "No error, but got unexpected response" , user ) ;
406
409
}
407
410
} )
408
411
. catch ( ( error ) => {
409
412
// This should be a failure to make the request, like the header command
410
413
// errored.
411
- storage . output . warn ( "Failed to check user authentication" , error ) ;
414
+ output . warn ( "Failed to check user authentication" , error ) ;
412
415
vscode . window . showErrorMessage (
413
416
`Failed to check user authentication: ${ error . message } ` ,
414
417
) ;
@@ -417,7 +420,7 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
417
420
vscode . commands . executeCommand ( "setContext" , "coder.loaded" , true ) ;
418
421
} ) ;
419
422
} else {
420
- storage . output . info ( "Not currently logged in" ) ;
423
+ output . info ( "Not currently logged in" ) ;
421
424
vscode . commands . executeCommand ( "setContext" , "coder.loaded" , true ) ;
422
425
423
426
// Handle autologin, if not already logged in.
0 commit comments