Skip to content

Commit deb627f

Browse files
authored
Wider support vscode support (#98)
1 parent fcc9b6e commit deb627f

File tree

3 files changed

+35
-27
lines changed

3 files changed

+35
-27
lines changed

src/commands/workspaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ export class ConnectInCurrentWindowCommand implements Command {
350350

351351
private async initializeLocalSSH(workspaceId: string) {
352352
try {
353+
await this.remoteService.updateRemoteSSHConfig(true, undefined);
353354
await Promise.all([
354355
this.remoteService.setupSSHProxy(),
355356
this.remoteService.startLocalSSHServiceServer()

src/remoteConnector.ts

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -580,31 +580,12 @@ export class RemoteConnector extends Disposable {
580580
});
581581
}
582582

583-
private async updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined) {
584-
const remoteSSHconfig = vscode.workspace.getConfiguration('remote.SSH');
585-
const defaultExtConfigInfo = remoteSSHconfig.inspect<string[]>('defaultExtensions');
586-
const defaultExtensions = defaultExtConfigInfo?.globalValue ?? [];
587-
if (!defaultExtensions.includes('gitpod.gitpod-remote-ssh')) {
588-
defaultExtensions.unshift('gitpod.gitpod-remote-ssh');
589-
await remoteSSHconfig.update('defaultExtensions', defaultExtensions, vscode.ConfigurationTarget.Global);
590-
}
591-
592-
const currentConfigFile = remoteSSHconfig.get<string>('configFile');
593-
if (usingSSHGateway) {
594-
if (currentConfigFile?.includes('gitpod_ssh_config')) {
595-
await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global);
596-
}
597-
} else {
598-
// TODO(ak) notify a user about config file changes?
599-
if (currentConfigFile === localAppSSHConfigPath) {
600-
// invalidate cached SSH targets from the current config file
601-
await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global);
602-
}
603-
await remoteSSHconfig.update('configFile', localAppSSHConfigPath, vscode.ConfigurationTarget.Global);
583+
private async ensureRemoteSSHExtInstalled(flow: UserFlowTelemetryProperties): Promise<boolean> {
584+
const isOfficialVscode = vscode.env.uriScheme === 'vscode' || vscode.env.uriScheme === 'vscode-insiders';
585+
if (!isOfficialVscode) {
586+
return true;
604587
}
605-
}
606588

607-
private async ensureRemoteSSHExtInstalled(flow: UserFlowTelemetryProperties): Promise<boolean> {
608589
const msVscodeRemoteExt = vscode.extensions.getExtension('ms-vscode-remote.remote-ssh');
609590
if (msVscodeRemoteExt) {
610591
return true;
@@ -704,7 +685,7 @@ export class RemoteConnector extends Disposable {
704685
try {
705686
this.telemetryService.sendUserFlowStatus('connecting', localSSHFlow);
706687
// If needed, revert local-app changes first
707-
await this.updateRemoteSSHConfig(true, undefined);
688+
await this.remoteService.updateRemoteSSHConfig(true, undefined);
708689

709690
this.remoteService.flow = sshFlow;
710691
await Promise.all([
@@ -834,7 +815,7 @@ export class RemoteConnector extends Disposable {
834815
}
835816
}
836817

837-
await this.updateRemoteSSHConfig(usingSSHGateway, localAppSSHConfigPath);
818+
await this.remoteService.updateRemoteSSHConfig(usingSSHGateway, localAppSSHConfigPath);
838819

839820
await this.context.globalState.update(`${SSH_DEST_KEY}${sshDestination!.toRemoteSSHString()}`, { ...params } as SSHConnectionParams);
840821

src/services/remoteService.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface IRemoteService {
4343
getWorkspaceSSHDestination(wsData: WorkspaceData): Promise<{ destination: SSHDestination; password?: string }>;
4444
showSSHPasswordModal(wsData: WorkspaceData, password: string): Promise<void>;
4545

46+
updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined): Promise<void>;
4647
initializeRemoteExtensions(): Promise<void>;
4748
}
4849

@@ -177,11 +178,12 @@ export class RemoteService extends Disposable implements IRemoteService {
177178
await SSHConfiguration.saveGitpodSSHConfig(gitpodConfig);
178179
}
179180

180-
private getHostSSHConfig(host: string, launcher: string, proxyScript: string, extIpcPort: number, logLevel:string) {
181+
private getHostSSHConfig(host: string, launcher: string, proxyScript: string, extIpcPort: number, logLevel: string) {
182+
const extraArgs = (process.versions['electron'] && process.versions['microsoft-build']) ? '--ms-enable-electron-run-as-node' : '';
181183
return {
182184
Host: '*.' + getLocalSSHDomain(host),
183185
StrictHostKeyChecking: 'no',
184-
ProxyCommand: `"${launcher}" "${process.execPath}" "${proxyScript}" --ms-enable-electron-run-as-node %h ${extIpcPort} ${vscode.env.machineId} ${logLevel}`
186+
ProxyCommand: `"${launcher}" "${process.execPath}" "${proxyScript}" ${extraArgs} %h ${extIpcPort} ${vscode.env.machineId} ${logLevel}`
185187
};
186188
}
187189

@@ -326,6 +328,30 @@ export class RemoteService extends Disposable implements IRemoteService {
326328
throw new Error('SSH password modal dialog, Canceled');
327329
}
328330

331+
async updateRemoteSSHConfig(usingSSHGateway: boolean, localAppSSHConfigPath: string | undefined) {
332+
const remoteSSHconfig = vscode.workspace.getConfiguration('remote.SSH');
333+
const defaultExtConfigInfo = remoteSSHconfig.inspect<string[]>('defaultExtensions');
334+
const defaultExtensions = defaultExtConfigInfo?.globalValue ?? [];
335+
if (!defaultExtensions.includes('gitpod.gitpod-remote-ssh')) {
336+
defaultExtensions.unshift('gitpod.gitpod-remote-ssh');
337+
await remoteSSHconfig.update('defaultExtensions', defaultExtensions, vscode.ConfigurationTarget.Global);
338+
}
339+
340+
const currentConfigFile = remoteSSHconfig.get<string>('configFile');
341+
if (usingSSHGateway) {
342+
if (currentConfigFile?.includes('gitpod_ssh_config')) {
343+
await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global);
344+
}
345+
} else {
346+
// TODO(ak) notify a user about config file changes?
347+
if (currentConfigFile === localAppSSHConfigPath) {
348+
// invalidate cached SSH targets from the current config file
349+
await remoteSSHconfig.update('configFile', undefined, vscode.ConfigurationTarget.Global);
350+
}
351+
await remoteSSHconfig.update('configFile', localAppSSHConfigPath, vscode.ConfigurationTarget.Global);
352+
}
353+
}
354+
329355
async initializeRemoteExtensions() {
330356
let flowData = this.flow ?? { gitpodHost: this.hostService.gitpodHost, userId: this.sessionService.safeGetUserId() };
331357
flowData = { ...flowData, flow: 'sync_local_extensions', useLocalAPP: String(Configuration.getUseLocalApp()) };

0 commit comments

Comments
 (0)