Skip to content

Commit 8791398

Browse files
test k8s
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 7457ce1 commit 8791398

1 file changed

Lines changed: 68 additions & 7 deletions

File tree

code/extensions/che-api/src/extension.ts

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,80 @@ import * as vscode from 'vscode';
2121
import { Api } from './api/api';
2222
import { DevfileService } from './api/devfile-service';
2323
import { K8SService } from './api/k8s-service';
24-
import { K8sDevfileServiceImpl } from './impl/k8s-devfile-service-impl';
25-
import { K8SServiceImpl } from './impl/k8s-service-impl';
26-
import { K8sDevWorkspaceEnvVariables } from './impl/k8s-devworkspace-env-variables';
2724
import { WorkspaceService } from './api/workspace-service';
28-
import { K8sWorkspaceServiceImpl } from './impl/k8s-workspace-service-impl';
2925
import { GithubService } from './api/github-service';
30-
import { GithubServiceImpl } from './impl/github-service-impl';
3126
import { TelemetryService } from './api/telemetry-service';
32-
import { K8sTelemetryServiceImpl } from './impl/k8s-telemetry-service-impl';
33-
import { Logger } from './logger';
3427

28+
const TEMP_DISABLE_K8S_CLIENT_NODE_FOR_DEBUG = true;
29+
30+
function unavailable(method: string): never {
31+
throw new Error(`che-api debug mode: ${method} is unavailable because @kubernetes/client-node path is disabled`);
32+
}
33+
34+
function createUnavailableApi(): Api {
35+
const devfileService = {
36+
getRaw: async () => unavailable('DevfileService.getRaw'),
37+
get: async () => unavailable('DevfileService.get'),
38+
updateDevfile: async () => unavailable('DevfileService.updateDevfile')
39+
} as unknown as DevfileService;
40+
const workspaceService = {
41+
getNamespace: async () => unavailable('WorkspaceService.getNamespace'),
42+
getWorkspaceId: async () => unavailable('WorkspaceService.getWorkspaceId'),
43+
getPodName: async () => unavailable('WorkspaceService.getPodName'),
44+
updateWorkspaceActivity: async () => unavailable('WorkspaceService.updateWorkspaceActivity'),
45+
stop: async () => unavailable('WorkspaceService.stop')
46+
} as WorkspaceService;
47+
const githubService = {
48+
getToken: async () => unavailable('GithubService.getToken'),
49+
persistDeviceAuthToken: async () => unavailable('GithubService.persistDeviceAuthToken'),
50+
removeDeviceAuthToken: async () => unavailable('GithubService.removeDeviceAuthToken'),
51+
getUser: async () => unavailable('GithubService.getUser'),
52+
getTokenScopes: async () => unavailable('GithubService.getTokenScopes')
53+
} as unknown as GithubService;
54+
const telemetryService = {
55+
submitTelemetryEvent: async () => unavailable('TelemetryService.submitTelemetryEvent'),
56+
submitTelemetryActivity: async () => unavailable('TelemetryService.submitTelemetryActivity')
57+
} as unknown as TelemetryService;
58+
59+
return {
60+
getDevfileService(): DevfileService {
61+
return devfileService;
62+
},
63+
getWorkspaceService(): WorkspaceService {
64+
return workspaceService;
65+
},
66+
getGithubService(): GithubService {
67+
return githubService;
68+
},
69+
getTelemetryService(): TelemetryService {
70+
return telemetryService;
71+
},
72+
};
73+
}
3574

3675
export async function activate(_extensionContext: vscode.ExtensionContext): Promise<Api> {
76+
if (TEMP_DISABLE_K8S_CLIENT_NODE_FOR_DEBUG) {
77+
console.error('[che-api] debug mode active; skipping imports that depend on @kubernetes/client-node');
78+
return createUnavailableApi();
79+
}
80+
81+
const [
82+
{ K8sDevfileServiceImpl },
83+
{ K8SServiceImpl },
84+
{ K8sDevWorkspaceEnvVariables },
85+
{ K8sWorkspaceServiceImpl },
86+
{ GithubServiceImpl },
87+
{ K8sTelemetryServiceImpl },
88+
{ Logger }
89+
] = await Promise.all([
90+
import('./impl/k8s-devfile-service-impl'),
91+
import('./impl/k8s-service-impl'),
92+
import('./impl/k8s-devworkspace-env-variables'),
93+
import('./impl/k8s-workspace-service-impl'),
94+
import('./impl/github-service-impl'),
95+
import('./impl/k8s-telemetry-service-impl'),
96+
import('./logger')
97+
]);
3798

3899
const container = new Container();
39100
container.bind(K8sDevfileServiceImpl).toSelf().inSingletonScope();

0 commit comments

Comments
 (0)