Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always update remotePlatform for gitpodHost's wildcard #103

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export async function activate(context: vscode.ExtensionContext) {

const hostService = new HostService(context, notificationService, logger);
context.subscriptions.push(hostService);
await hostService.updateSSHRemotePlatform();
mustard-mh marked this conversation as resolved.
Show resolved Hide resolved

const sessionService = new SessionService(hostService, logger);
context.subscriptions.push(sessionService);
Expand Down
9 changes: 0 additions & 9 deletions src/remoteConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { INotificationService } from './services/notificationService';
import { SSHKey } from '@gitpod/public-api/lib/gitpod/experimental/v1/user_pb';
import { getAgentSock, SSHError, testSSHConnection as testSSHGatewayConnection } from './sshTestConnection';
import { gatherIdentityFiles } from './ssh/identityFiles';
import { isWindows } from './common/platform';
import SSHDestination from './ssh/sshDestination';
import { NoRunningInstanceError, NoSSHGatewayError, SSHConnectionParams, SSH_DEST_KEY, getLocalSSHDomain } from './remote';
import { ISessionService } from './services/sessionService';
Expand Down Expand Up @@ -361,14 +360,6 @@ export class RemoteConnector extends Disposable {

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

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

return sshDestination;
}
);
Expand Down
16 changes: 16 additions & 0 deletions src/services/hostService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface IHostService {
onDidChangeHost: vscode.Event<void>;

changeHost(newHost: string, force?: boolean): Promise<boolean>;
updateSSHRemotePlatform(): Promise<void>;
}

export class HostService extends Disposable implements IHostService {
Expand Down Expand Up @@ -51,6 +52,7 @@ export class HostService extends Disposable implements IHostService {
if (new URL(this._gitpodHost).host !== new URL(newGitpodHost).host) {
this._gitpodHost = newGitpodHost;
this._onDidChangeHost.fire();
this.updateSSHRemotePlatform().then(() => {});
}
}
}));
Expand Down Expand Up @@ -78,4 +80,18 @@ export class HostService extends Disposable implements IHostService {
}
return true;
}

// Force Linux as host platform (https://github.com/gitpod-io/gitpod/issues/16058)
async updateSSHRemotePlatform() {
try {
const hostname = '*.' + (new URL(this.gitpodHost)).hostname;
const existingSSHHostPlatforms = vscode.workspace.getConfiguration('remote.SSH').get<{ [host: string]: string }>('remotePlatform', {});
const targetPlatform = 'linux';
if (!existingSSHHostPlatforms[hostname] || existingSSHHostPlatforms[hostname] !== targetPlatform) {
await vscode.workspace.getConfiguration('remote.SSH').update('remotePlatform', { ...existingSSHHostPlatforms, [hostname]: targetPlatform }, vscode.ConfigurationTarget.Global);
}
} catch (error) {
this.logService.error('Error updating remotePlatform configuration', error);
}
}
mustard-mh marked this conversation as resolved.
Show resolved Hide resolved
}
Loading