integration: GitLab API should be added for default and should have a protocol

This commit is contained in:
Himanshu Mishra
2021-01-17 10:43:39 +01:00
parent 294a70caba
commit fa8ba330a8
3 changed files with 20 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/integration': patch
---
Fix GitLab API base URL and add it by default to the gitlab.com host
+13 -1
View File
@@ -43,7 +43,18 @@ describe('readGitLabIntegrationConfig', () => {
const output = readGitLabIntegrationConfig(buildConfig({}));
expect(output).toEqual({
host: 'gitlab.com',
apiBaseUrl: 'gitlab.com/api/v4',
apiBaseUrl: 'https://gitlab.com/api/v4',
});
});
it('injects the correct GitLab API base URL when missing', () => {
const output = readGitLabIntegrationConfig(
buildConfig({ host: 'gitlab.com' }),
);
expect(output).toEqual({
host: 'gitlab.com',
apiBaseUrl: 'https://gitlab.com/api/v4',
});
});
@@ -86,6 +97,7 @@ describe('readGitLabIntegrationConfigs', () => {
expect(output).toEqual([
{
host: 'gitlab.com',
apiBaseUrl: 'https://gitlab.com/api/v4',
},
]);
});
+2 -2
View File
@@ -18,7 +18,7 @@ import { Config } from '@backstage/config';
import { isValidHost } from '../helpers';
const GITLAB_HOST = 'gitlab.com';
const GITLAB_API_BASE_URL = 'gitlab.com/api/v4';
const GITLAB_API_BASE_URL = 'https://gitlab.com/api/v4';
/**
* The configuration parameters for a single GitLab integration.
@@ -89,7 +89,7 @@ export function readGitLabIntegrationConfigs(
// As a convenience we always make sure there's at least an unauthenticated
// reader for public gitlab repos.
if (!result.some(c => c.host === GITLAB_HOST)) {
result.push({ host: GITLAB_HOST });
result.push({ host: GITLAB_HOST, apiBaseUrl: GITLAB_API_BASE_URL });
}
return result;