Skip to content

Commit eab7f5f

Browse files
test
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 2291cbe commit eab7f5f

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

code/extensions/che-api/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
"supported": true
2222
}
2323
},
24+
"contributes": {
25+
"commands": [
26+
{
27+
"command": "che-api.test-github-proxy",
28+
"title": "Test GitHub Proxy (axios)"
29+
}
30+
]
31+
},
2432
"main": "./out/extension.js",
2533
"scripts": {
2634
"compile": "gulp compile-extension:che-api",

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,16 @@ export async function activate(_extensionContext: vscode.ExtensionContext): Prom
8181

8282
await container.get(K8SServiceImpl).ensureKubernetesServiceHostWhitelisted();
8383

84+
_extensionContext.subscriptions.push(
85+
vscode.commands.registerCommand('che-api.test-github-proxy', async () => {
86+
try {
87+
const user = await githubService.getUser();
88+
vscode.window.showInformationMessage(`Success! GitHub user: ${user.login}`);
89+
} catch (e: any) {
90+
vscode.window.showErrorMessage(`Failed to get GitHub user: ${e.message}`);
91+
}
92+
})
93+
);
94+
8495
return api;
8596
}

code/extensions/che-api/src/impl/github-service-impl.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export class GithubServiceImpl implements GithubService {
6161
private async initializeToken(): Promise<void> {
6262
this.logger.info('Github Service: extracting token...');
6363

64+
if (process.env.GITHUB_TEST_TOKEN) {
65+
this.token = process.env.GITHUB_TEST_TOKEN;
66+
this.logger.info('Github Service: using token from GITHUB_TEST_TOKEN env variable');
67+
return;
68+
} else {
69+
this.logger.info('Github Service: NO token from GITHUB_TEST_TOKEN env variable');
70+
}
71+
6472
const deviceAuthToken = await this.getDeviceAuthToken();
6573
if (deviceAuthToken) {
6674
this.token = deviceAuthToken;

0 commit comments

Comments
 (0)