Skip to content

Commit 0081d9f

Browse files
committed
🧹
1 parent 4085871 commit 0081d9f

File tree

8 files changed

+3
-225
lines changed

8 files changed

+3
-225
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
"@types/mocha": "^9.1.1",
149149
"@types/node": "16.x",
150150
"@types/proper-lockfile": "^4.1.2",
151-
"@types/ps-node": "^0.1.1",
152151
"@types/semver": "^7.3.10",
153152
"@types/ssh2": "^0.5.52",
154153
"@types/tmp": "^0.2.1",
@@ -195,7 +194,6 @@
195194
"prom-client": "^14.1.1",
196195
"proper-lockfile": "^4.1.2",
197196
"protobufjs": "^7.2.2",
198-
"ps-node": "^0.1.6",
199197
"semver": "^7.3.7",
200198
"ssh-config": "^4.1.6",
201199
"ssh2": "^1.10.0",

src/common/telemetry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface UserFlowTelemetryProperties {
2222
flow: string;
2323

2424
gitpodHost: string;
25-
gitpodVersion?: string;
2625

2726
workspaceId?: string;
2827
instanceId?: string;

src/featureSupport.ts

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -2,120 +2,6 @@
22
* Copyright (c) Gitpod. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
import * as vscode from 'vscode';
6-
import * as semver from 'semver';
7-
import { retry } from './common/async';
8-
import { ILogService } from './services/logService';
9-
10-
export class GitpodVersion {
11-
static MAX_VERSION = '9999.99.99';
12-
static MIN_VERSION = '0.0.0';
13-
14-
static Max = new GitpodVersion(GitpodVersion.MAX_VERSION);
15-
static Min = new GitpodVersion(GitpodVersion.MIN_VERSION);
16-
17-
readonly version: string;
18-
readonly raw: string;
19-
20-
constructor(gitpodVersion: string) {
21-
this.raw = gitpodVersion;
22-
this.version = GitpodVersion.MIN_VERSION;
23-
24-
// Check for yyyy.mm.dd format
25-
const match = /(?:\.|-|^)(\d{4}\.\d{1,2}\.\d{1,2})(?:\.|-|$)/.exec(gitpodVersion);
26-
if (match) {
27-
// Remove leading zeros to make it a valid semver
28-
const [yy, mm, dd] = match[1].split('.');
29-
gitpodVersion = `${parseInt(yy, 10)}.${parseInt(mm, 10)}.${parseInt(dd, 10)}`;
30-
31-
}
32-
33-
if (semver.valid(gitpodVersion)) {
34-
this.version = gitpodVersion;
35-
}
36-
}
37-
}
38-
39-
let cacheGitpodVersion: { host: string; version: GitpodVersion } | undefined;
40-
async function getOrFetchVersionInfo(serviceUrl: string, logger: ILogService) {
41-
if (serviceUrl === 'https://gitpod.io') {
42-
// SaaS default allow all features, should proper handle SaaS feature support if needed in the future
43-
return {
44-
host: serviceUrl,
45-
version: GitpodVersion.Max,
46-
};
47-
}
48-
49-
if (serviceUrl === cacheGitpodVersion?.host) {
50-
return cacheGitpodVersion;
51-
}
52-
53-
const versionEndPoint = `${serviceUrl}/api/version`;
54-
let gitpodRawVersion: string | undefined;
55-
try {
56-
gitpodRawVersion = await retry(async () => {
57-
const controller = new AbortController();
58-
setTimeout(() => controller.abort(), 1500);
59-
const resp = await fetch(versionEndPoint, { signal: controller.signal });
60-
if (!resp.ok) {
61-
throw new Error(`Responded with ${resp.status} ${resp.statusText}`);
62-
}
63-
return resp.text();
64-
}, 1000, 3);
65-
} catch (e) {
66-
logger.error(`Error while fetching ${versionEndPoint}`, e);
67-
}
68-
69-
if (!gitpodRawVersion) {
70-
logger.info(`Failed to fetch version from ${versionEndPoint}, some feature will be disabled`);
71-
return {
72-
host: serviceUrl,
73-
version: GitpodVersion.Min,
74-
};
75-
}
76-
77-
logger.info(`Got version from: ${serviceUrl} version: ${gitpodRawVersion}`);
78-
79-
cacheGitpodVersion = {
80-
host: serviceUrl,
81-
version: new GitpodVersion(gitpodRawVersion)
82-
};
83-
return cacheGitpodVersion;
84-
}
85-
86-
export async function getGitpodVersion(gitpodHost: string, logger: ILogService) {
87-
const serviceUrl = new URL(gitpodHost).toString().replace(/\/$/, '');
88-
const versionInfo = await getOrFetchVersionInfo(serviceUrl, logger);
89-
return versionInfo.version;
90-
}
91-
92-
type Feature = |
93-
'SSHPublicKeys' |
94-
'localHeartbeat';
95-
96-
export function isFeatureSupported(gitpodVersion: GitpodVersion, feature: Feature) {
97-
switch (feature) {
98-
case 'SSHPublicKeys':
99-
case 'localHeartbeat':
100-
return semver.gte(gitpodVersion.version, '2022.7.0'); // Don't use leading zeros
101-
}
102-
}
103-
104-
export async function isOauthInspectSupported(gitpodHost: string,) {
105-
const serviceUrl = new URL(gitpodHost).toString().replace(/\/$/, '');
106-
const endpoint = `${serviceUrl}/api/oauth/inspect?client=${vscode.env.uriScheme}-gitpod`;
107-
try {
108-
const controller = new AbortController();
109-
setTimeout(() => controller.abort(), 1500);
110-
const resp = await fetch(endpoint, { signal: controller.signal });
111-
if (resp.ok) {
112-
return true;
113-
}
114-
} catch {
115-
}
116-
117-
return false;
118-
}
1195

1206
export enum ScopeFeature {
1217
SSHPublicKeys = 'function:getSSHPublicKeys',

src/remoteConnector.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,7 @@ export class RemoteConnector extends Disposable {
507507
if (identityKeys.length) {
508508
user = `${user}#${ownerToken}`;
509509
}
510-
const gitpodVersion = await this.hostService.getVersion();
511-
this.logService.warn(`Registered SSH public keys not supported in ${gitpodHost}, using version ${gitpodVersion.raw}`);
510+
this.logService.warn(`Registered SSH public keys not supported in ${gitpodHost}`);
512511
}
513512

514513
return {
@@ -675,7 +674,6 @@ export class RemoteConnector extends Disposable {
675674
}
676675

677676
sshFlow.userId = this.sessionService.getUserId();
678-
sshFlow.gitpodVersion = (await this.hostService.getVersion()).raw;
679677

680678
this.logService.info('Opening Gitpod workspace', uri.toString());
681679

src/remoteSession.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { ITelemetryService, UserFlowTelemetryProperties } from './common/telemet
1515
import { INotificationService } from './services/notificationService';
1616
import { retry } from './common/async';
1717
import { withServerApi } from './internalApi';
18-
import { ScopeFeature } from './featureSupport';
1918
import { ISessionService } from './services/sessionService';
2019
import { IHostService } from './services/hostService';
2120
import { ILogService } from './services/logService';
@@ -100,16 +99,9 @@ export class RemoteSession extends Disposable {
10099
const { sshDestStr } = getGitpodRemoteWindowConnectionInfo(this.context)!;
101100
await this.context.globalState.update(`${SSH_DEST_KEY}${sshDestStr}`, { ...this.connectionInfo } as SSHConnectionParams);
102101

103-
const gitpodVersion = await this.hostService.getVersion();
102+
this.heartbeatManager = new HeartbeatManager(this.connectionInfo, this.workspaceState, this.sessionService, this.logService, this.telemetryService);
104103

105-
const heartbeatSupported = this.sessionService.getScopes().includes(ScopeFeature.LocalHeartbeat);
106-
if (heartbeatSupported) {
107-
this.heartbeatManager = new HeartbeatManager(this.connectionInfo, this.workspaceState, this.sessionService, this.logService, this.telemetryService);
108-
} else {
109-
this.logService.error(`Local heartbeat not supported in ${this.connectionInfo.gitpodHost}, using version ${gitpodVersion.raw}`);
110-
}
111-
112-
const syncExtFlow = { ...this.connectionInfo, gitpodVersion: gitpodVersion.raw, userId: this.sessionService.getUserId(), flow: 'sync_local_extensions' };
104+
const syncExtFlow = { ...this.connectionInfo, userId: this.sessionService.getUserId(), flow: 'sync_local_extensions' };
113105
this.initializeRemoteExtensions({ ...syncExtFlow, quiet: true, flowId: uuid() });
114106
this._register(vscode.commands.registerCommand('gitpod.installLocalExtensions', () => {
115107
this.initializeRemoteExtensions({ ...syncExtFlow, quiet: false, flowId: uuid() });

src/services/hostService.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import * as vscode from 'vscode';
77
import { Disposable } from '../common/dispose';
8-
import { GitpodVersion, getGitpodVersion } from '../featureSupport';
98
import { INotificationService } from './notificationService';
109
import { getGitpodRemoteWindowConnectionInfo } from '../remote';
1110
import { UserFlowTelemetryProperties } from '../common/telemetry';
@@ -18,13 +17,11 @@ export interface IHostService {
1817
onDidChangeHost: vscode.Event<void>;
1918

2019
changeHost(newHost: string, force?: boolean): Promise<boolean>;
21-
getVersion(): Promise<GitpodVersion>;
2220
}
2321

2422
export class HostService extends Disposable implements IHostService {
2523

2624
private _gitpodHost: string;
27-
private _version: GitpodVersion | undefined;
2825

2926
private readonly _onDidChangeHost = this._register(new vscode.EventEmitter<void>());
3027
public readonly onDidChangeHost = this._onDidChangeHost.event;
@@ -53,7 +50,6 @@ export class HostService extends Disposable implements IHostService {
5350
const newGitpodHost = Configuration.getGitpodHost();
5451
if (new URL(this._gitpodHost).host !== new URL(newGitpodHost).host) {
5552
this._gitpodHost = newGitpodHost;
56-
this._version = undefined;
5753
this._onDidChangeHost.fire();
5854
}
5955
}
@@ -82,11 +78,4 @@ export class HostService extends Disposable implements IHostService {
8278
}
8379
return true;
8480
}
85-
86-
async getVersion() {
87-
if (!this._version) {
88-
this._version = await getGitpodVersion(this._gitpodHost, this.logService);
89-
}
90-
return this._version;
91-
}
9281
}

src/test/featureSupport.test.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

yarn.lock

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,6 @@
466466
dependencies:
467467
"@types/retry" "*"
468468

469-
"@types/ps-node@^0.1.1":
470-
version "0.1.1"
471-
resolved "https://registry.yarnpkg.com/@types/ps-node/-/ps-node-0.1.1.tgz#fbbb7a0c55bf4e945756c023ccd205576f6177d2"
472-
integrity sha512-t/8CsMBQ1ekBIb+Soqxce6w8M7yt0jRoXgsWHkS66VQ9OcMDQeoRLzz+gGpVeBc8pVskOTwRbCqHxDOGFwkgsg==
473-
474469
475470
version "17.0.32"
476471
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.32.tgz#89a161286bbe2325d4d516420a27364a324909f4"
@@ -1366,11 +1361,6 @@ configcat-node@^8.0.0:
13661361
configcat-common "^6.0.0"
13671362
tunnel "0.0.6"
13681363

1369-
connected-domain@^1.0.0:
1370-
version "1.0.0"
1371-
resolved "https://registry.yarnpkg.com/connected-domain/-/connected-domain-1.0.0.tgz#bfe77238c74be453a79f0cb6058deeb4f2358e93"
1372-
integrity sha512-lHlohUiJxlpunvDag2Y0pO20bnvarMjnrdciZeuJUqRwrf/5JHNhdpiPIr5GQ8IkqrFj5TDMQwcCjblGo1oeuA==
1373-
13741364
console-control-strings@^1.0.0, console-control-strings@^1.1.0:
13751365
version "1.1.0"
13761366
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
@@ -3247,13 +3237,6 @@ proxy-addr@~2.0.7:
32473237
forwarded "0.2.0"
32483238
ipaddr.js "1.9.1"
32493239

3250-
ps-node@^0.1.6:
3251-
version "0.1.6"
3252-
resolved "https://registry.yarnpkg.com/ps-node/-/ps-node-0.1.6.tgz#9af67a99d7b1d0132e51a503099d38a8d2ace2c3"
3253-
integrity sha512-w7QJhUTbu70hpDso0YXDRNKCPNuchV8UTUZsAv0m7Qj5g85oHOJfr9drA1EjvK4nQK/bG8P97W4L6PJ3IQLoOA==
3254-
dependencies:
3255-
table-parser "^0.1.3"
3256-
32573240
pump@^3.0.0:
32583241
version "3.0.0"
32593242
resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64"
@@ -3769,13 +3752,6 @@ supports-preserve-symlinks-flag@^1.0.0:
37693752
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
37703753
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==
37713754

3772-
table-parser@^0.1.3:
3773-
version "0.1.3"
3774-
resolved "https://registry.yarnpkg.com/table-parser/-/table-parser-0.1.3.tgz#0441cfce16a59481684c27d1b5a67ff15a43c7b0"
3775-
integrity sha512-LCYeuvqqoPII3lzzYaXKbC3Forb+d2u4bNwhk/9FlivuGRxPE28YEWAYcujeSlLLDlMfvy29+WPybFJZFiKMYg==
3776-
dependencies:
3777-
connected-domain "^1.0.0"
3778-
37793755
tapable@^2.1.1, tapable@^2.2.0:
37803756
version "2.2.1"
37813757
resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0"

0 commit comments

Comments
 (0)