Skip to content

Commit 7731ba5

Browse files
authored
Merge pull request #611 from kubero-dev/feature/add-github-baseURL
Update GithubApi constructor to include baseUrl parameter and set de…
2 parents 173368d + 59cc83b commit 7731ba5

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

server/src/git/github.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ import { RequestError } from '@octokit/types';
1212
export class GithubApi extends Repo {
1313
private octokit: any;
1414

15-
constructor(token: string) {
15+
constructor(baseUrl: string, token: string) {
1616
super("github");
17+
18+
if (baseUrl === '') {
19+
baseUrl = 'https://api.github.com';
20+
}
21+
1722
this.octokit = new Octokit({
18-
auth: token
23+
auth: token,
24+
baseUrl: baseUrl,
1925
});
2026
}
2127

server/src/git/repo.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { GiteaApi } from './gitea';
66

77
describe('GithubApi', () => {
88
it('should load config', () => {
9-
const github = new GithubApi("token");
9+
const github = new GithubApi('', "token");
1010
expect(github).toBeTruthy();
1111
});
1212
});

server/src/kubero.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class Kubero {
8080

8181
this.giteaApi = new GiteaApi(process.env.GITEA_BASEURL as string, process.env.GITEA_PERSONAL_ACCESS_TOKEN as string);
8282
this.gogsApi = new GogsApi(process.env.GOGS_BASEURL as string, process.env.GOGS_PERSONAL_ACCESS_TOKEN as string);
83-
this.githubApi = new GithubApi(process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string);
83+
this.githubApi = new GithubApi(process.env.GITHUB_BASEURL as string, process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string);
8484
this.gitlabApi = new GitlabApi(process.env.GITLAB_BASEURL as string, process.env.GITLAB_PERSONAL_ACCESS_TOKEN as string);
8585
this.bitbucketApi = new BitbucketApi(process.env.BITBUCKET_USERNAME as string, process.env.BITBUCKET_APP_PASSWORD as string);
8686

server/src/modules/repositories.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class Repositories {
1616
constructor() {
1717
this.giteaApi = new GiteaApi(process.env.GITEA_BASEURL as string, process.env.GITEA_PERSONAL_ACCESS_TOKEN as string);
1818
this.gogsApi = new GogsApi(process.env.GOGS_BASEURL as string, process.env.GOGS_PERSONAL_ACCESS_TOKEN as string);
19-
this.githubApi = new GithubApi(process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string);
19+
this.githubApi = new GithubApi(process.env.GITHUB_BASEURL as string, process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string);
2020
this.gitlabApi = new GitlabApi(process.env.GITLAB_BASEURL as string, process.env.GITLAB_PERSONAL_ACCESS_TOKEN as string);
2121
this.bitbucketApi = new BitbucketApi(process.env.BITBUCKET_USERNAME as string, process.env.BITBUCKET_APP_PASSWORD as string);
2222
}

0 commit comments

Comments
 (0)