Skip to content

Commit d672ab8

Browse files
committed
Always update remotePlatform for gitpodHost's wildcard
1 parent edbfdcf commit d672ab8

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/extension.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {
7979

8080
const hostService = new HostService(context, notificationService, logger);
8181
context.subscriptions.push(hostService);
82+
await hostService.updateSSHRemotePlatform();
8283

8384
const sessionService = new SessionService(hostService, logger);
8485
context.subscriptions.push(sessionService);

src/remoteConnector.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { INotificationService } from './services/notificationService';
2121
import { SSHKey } from '@gitpod/public-api/lib/gitpod/experimental/v1/user_pb';
2222
import { getAgentSock, SSHError, testSSHConnection as testSSHGatewayConnection } from './sshTestConnection';
2323
import { gatherIdentityFiles } from './ssh/identityFiles';
24-
import { isWindows } from './common/platform';
2524
import SSHDestination from './ssh/sshDestination';
2625
import { NoRunningInstanceError, NoSSHGatewayError, SSHConnectionParams, SSH_DEST_KEY, getLocalSSHDomain } from './remote';
2726
import { ISessionService } from './services/sessionService';
@@ -361,14 +360,6 @@ export class RemoteConnector extends Disposable {
361360

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

364-
// Force Linux as host platform (https://github.com/gitpod-io/gitpod/issues/16058)
365-
if (isWindows) {
366-
const existingSSHHostPlatforms = vscode.workspace.getConfiguration('remote.SSH').get<{ [host: string]: string }>('remotePlatform', {});
367-
if (!existingSSHHostPlatforms[sshDestination!.hostname]) {
368-
await vscode.workspace.getConfiguration('remote.SSH').update('remotePlatform', { ...existingSSHHostPlatforms, [sshDestination!.hostname]: 'linux' }, vscode.ConfigurationTarget.Global);
369-
}
370-
}
371-
372363
return sshDestination;
373364
}
374365
);

src/services/hostService.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface IHostService {
1717
onDidChangeHost: vscode.Event<void>;
1818

1919
changeHost(newHost: string, force?: boolean): Promise<boolean>;
20+
updateSSHRemotePlatform(): Promise<void>;
2021
}
2122

2223
export class HostService extends Disposable implements IHostService {
@@ -51,6 +52,7 @@ export class HostService extends Disposable implements IHostService {
5152
if (new URL(this._gitpodHost).host !== new URL(newGitpodHost).host) {
5253
this._gitpodHost = newGitpodHost;
5354
this._onDidChangeHost.fire();
55+
this.updateSSHRemotePlatform().then(() => {});
5456
}
5557
}
5658
}));
@@ -78,4 +80,18 @@ export class HostService extends Disposable implements IHostService {
7880
}
7981
return true;
8082
}
83+
84+
// Force Linux as host platform (https://github.com/gitpod-io/gitpod/issues/16058)
85+
async updateSSHRemotePlatform() {
86+
try {
87+
const hostname = '*.' + (new URL(this.gitpodHost)).hostname;
88+
const existingSSHHostPlatforms = vscode.workspace.getConfiguration('remote.SSH').get<{ [host: string]: string }>('remotePlatform', {});
89+
const targetPlatform = 'linux';
90+
if (!existingSSHHostPlatforms[hostname] || existingSSHHostPlatforms[hostname] !== targetPlatform) {
91+
await vscode.workspace.getConfiguration('remote.SSH').update('remotePlatform', { ...existingSSHHostPlatforms, [hostname]: targetPlatform }, vscode.ConfigurationTarget.Global);
92+
}
93+
} catch (error) {
94+
this.logService.error('Error updating remotePlatform configuration', error);
95+
}
96+
}
8197
}

0 commit comments

Comments
 (0)