@@ -9,64 +9,80 @@ import { INotificationService } from './services/notificationService';
9
9
import { ILogService } from './services/logService' ;
10
10
11
11
export interface SSHConnectionParams {
12
- workspaceId : string ;
13
- instanceId : string ;
14
- gitpodHost : string ;
15
- debugWorkspace ?: boolean ;
16
- connType ?: 'local-app' | 'local-ssh' | 'ssh-gateway' ;
12
+ workspaceId : string ;
13
+ instanceId : string ;
14
+ gitpodHost : string ;
15
+ debugWorkspace ?: boolean ;
16
+ connType ?: 'local-app' | 'local-ssh' | 'ssh-gateway' ;
17
17
}
18
18
19
19
export interface WorkspaceRestartInfo {
20
- workspaceId : string ;
21
- gitpodHost : string ;
20
+ workspaceId : string ;
21
+ gitpodHost : string ;
22
22
}
23
23
24
24
export class NoRunningInstanceError extends Error {
25
- constructor ( readonly workspaceId : string , readonly phase ?: string ) {
26
- super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running: ${ phase } ` ) ;
27
- }
25
+ code = 'NoRunningInstanceError' ;
26
+ constructor ( readonly workspaceId : string , readonly phase ?: string ) {
27
+ super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running: ${ phase } ` ) ;
28
+ }
28
29
}
29
30
30
31
export class NoSSHGatewayError extends Error {
31
- constructor ( readonly host : string ) {
32
- super ( `SSH gateway not configured for this Gitpod Host ${ host } ` ) ;
33
- }
32
+ code = 'NoSSHGatewayError' ;
33
+ constructor ( readonly host : string ) {
34
+ super ( `SSH gateway not configured for this Gitpod Host ${ host } ` ) ;
35
+ }
36
+ }
37
+
38
+ export class NoExtensionIPCServerError extends Error {
39
+ code = 'NoExtensionIPCServer' ;
40
+ constructor ( ) {
41
+ super ( 'NoExtensionIPCServer' ) ;
42
+ }
43
+ }
44
+
45
+ export class NoLocalSSHSupportError extends Error {
46
+ code = 'NoLocalSSHSupport' ;
47
+ constructor ( ) {
48
+ super ( 'NoLocalSSHSupport' ) ;
49
+ }
34
50
}
35
51
36
52
export const SSH_DEST_KEY = 'ssh-dest:' ;
37
53
38
54
export function getGitpodRemoteWindowConnectionInfo ( context : vscode . ExtensionContext ) : { remoteAuthority : string ; connectionInfo : SSHConnectionParams } | undefined {
39
- const remoteUri = vscode . workspace . workspaceFile || vscode . workspace . workspaceFolders ?. [ 0 ] . uri ;
40
- if ( vscode . env . remoteName === 'ssh-remote' && context . extension . extensionKind === vscode . ExtensionKind . UI && remoteUri ) {
41
- const [ , sshDestStr ] = remoteUri . authority . split ( '+' ) ;
42
- const connectionInfo = context . globalState . get < SSHConnectionParams > ( `${ SSH_DEST_KEY } ${ sshDestStr } ` ) ;
43
- if ( connectionInfo ) {
44
- return { remoteAuthority : remoteUri . authority , connectionInfo } ;
45
- }
46
- }
55
+ const remoteUri = vscode . workspace . workspaceFile || vscode . workspace . workspaceFolders ?. [ 0 ] . uri ;
56
+ if ( vscode . env . remoteName === 'ssh-remote' && context . extension . extensionKind === vscode . ExtensionKind . UI && remoteUri ) {
57
+ const [ , sshDestStr ] = remoteUri . authority . split ( '+' ) ;
58
+ const connectionInfo = context . globalState . get < SSHConnectionParams > ( `${ SSH_DEST_KEY } ${ sshDestStr } ` ) ;
59
+ if ( connectionInfo ) {
60
+ return { remoteAuthority : remoteUri . authority , connectionInfo } ;
61
+ }
62
+ }
47
63
48
- return undefined ;
64
+ return undefined ;
49
65
}
50
66
51
67
export async function showWsNotRunningDialog ( workspaceId : string , gitpodHost : string , flow : UserFlowTelemetryProperties , notificationService : INotificationService , logService : ILogService ) {
52
- const msg = `Workspace ${ workspaceId } is not running. Please restart the workspace.` ;
53
- logService . error ( msg ) ;
68
+ const msg = `Workspace ${ workspaceId } is not running. Please restart the workspace.` ;
69
+ logService . error ( msg ) ;
54
70
55
- const workspaceUrl = new URL ( gitpodHost ) ;
56
- workspaceUrl . pathname = '/start' ;
57
- workspaceUrl . hash = workspaceId ;
71
+ const workspaceUrl = new URL ( gitpodHost ) ;
72
+ workspaceUrl . pathname = '/start' ;
73
+ workspaceUrl . hash = workspaceId ;
58
74
59
- const openUrl = 'Restart workspace' ;
60
- const resp = await notificationService . showErrorMessage ( msg , { id : 'ws_not_running' , flow, modal : true } , openUrl ) ;
61
- if ( resp === openUrl ) {
62
- const opened = await vscode . env . openExternal ( vscode . Uri . parse ( workspaceUrl . toString ( ) ) ) ;
63
- if ( opened ) {
64
- vscode . commands . executeCommand ( 'workbench.action.closeWindow' ) ;
65
- }
66
- }
75
+ const openUrl = 'Restart workspace' ;
76
+ const resp = await notificationService . showErrorMessage ( msg , { id : 'ws_not_running' , flow, modal : true } , openUrl ) ;
77
+ if ( resp === openUrl ) {
78
+ const opened = await vscode . env . openExternal ( vscode . Uri . parse ( workspaceUrl . toString ( ) ) ) ;
79
+ if ( opened ) {
80
+ vscode . commands . executeCommand ( 'workbench.action.closeWindow' ) ;
81
+ }
82
+ }
67
83
}
68
84
69
85
export function getLocalSSHDomain ( gitpodHost : string ) : string {
70
- const scope = vscode . env . appName . includes ( 'Insiders' ) ? 'vsi' : 'vss' ;
71
- return `${ scope } .` + ( new URL ( gitpodHost ) ) . hostname ;
86
+ const scope = vscode . env . appName . includes ( 'Insiders' ) ? 'vsi' : 'vss' ;
87
+ return `${ scope } .` + ( new URL ( gitpodHost ) ) . hostname ;
72
88
}
0 commit comments