TechDocs Backend: Replace hardcoded github api by configuration value (#3004)
* replace hardcoded by configuration value * use integrations configuration to read github apiBaseUrl Co-authored-by: Emre Konar <emre.konar@zalando.de>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-techdocs-backend': patch
|
||||
---
|
||||
|
||||
Replacing the hard coded `baseApiUrl` by reading the value from configuration to enable private GitHub setup for TechDocs.
|
||||
@@ -42,9 +42,11 @@ interface IGitlabBranch {
|
||||
};
|
||||
}
|
||||
|
||||
function getGithubApiUrl(url: string): URL {
|
||||
function getGithubApiUrl(config: Config, url: string): URL {
|
||||
const { protocol, owner, name } = parseGitUrl(url);
|
||||
const apiBaseUrl = 'api.github.com';
|
||||
const apiBaseUrl =
|
||||
config.getOptionalString('integrations.github.apiBaseUrl') ||
|
||||
'api.github.com';
|
||||
const apiRepos = 'repos';
|
||||
|
||||
return new URL(`${protocol}://${apiBaseUrl}/${apiRepos}/${owner}/${name}`);
|
||||
@@ -133,7 +135,7 @@ async function getGithubDefaultBranch(
|
||||
repositoryUrl: string,
|
||||
config: Config,
|
||||
): Promise<string> {
|
||||
const path = getGithubApiUrl(repositoryUrl).toString();
|
||||
const path = getGithubApiUrl(config, repositoryUrl).toString();
|
||||
const options = getGithubRequestOptions(config);
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user