Skip to content
Snippets Groups Projects
Unverified Commit 7eef0d3e authored by Mike Glazer's avatar Mike Glazer Committed by GitHub
Browse files

feat(datasource/orb): Add support for internal CircleCI Registries (#33213)

parent 91c04835
No related branches found
Tags 39.79.0
No related merge requests found
...@@ -4,7 +4,7 @@ exports[`modules/datasource/orb/index getReleases processes homeUrl 1`] = ` ...@@ -4,7 +4,7 @@ exports[`modules/datasource/orb/index getReleases processes homeUrl 1`] = `
{ {
"homepage": "https://google.com", "homepage": "https://google.com",
"isPrivate": false, "isPrivate": false,
"registryUrl": "https://circleci.com/", "registryUrl": "https://circleci.com",
"releases": [ "releases": [
{ {
"releaseTimestamp": "2018-12-11T05:28:14.080Z", "releaseTimestamp": "2018-12-11T05:28:14.080Z",
...@@ -53,7 +53,7 @@ exports[`modules/datasource/orb/index getReleases processes real data 1`] = ` ...@@ -53,7 +53,7 @@ exports[`modules/datasource/orb/index getReleases processes real data 1`] = `
{ {
"homepage": "https://circleci.com/developer/orbs/orb/hyper-expanse/library-release-workflows", "homepage": "https://circleci.com/developer/orbs/orb/hyper-expanse/library-release-workflows",
"isPrivate": false, "isPrivate": false,
"registryUrl": "https://circleci.com/", "registryUrl": "https://circleci.com",
"releases": [ "releases": [
{ {
"releaseTimestamp": "2018-12-11T05:28:14.080Z", "releaseTimestamp": "2018-12-11T05:28:14.080Z",
......
...@@ -92,5 +92,18 @@ describe('modules/datasource/orb/index', () => { ...@@ -92,5 +92,18 @@ describe('modules/datasource/orb/index', () => {
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res?.homepage).toBe('https://google.com'); expect(res?.homepage).toBe('https://google.com');
}); });
it('supports other registries', async () => {
httpMock
.scope('https://cci.internal.dev')
.post('/graphql-unstable')
.reply(200, orbData);
const res = await getPkgReleases({
datasource,
packageName: 'hyper-expanse/library-release-workflows',
registryUrls: ['https://cci.internal.dev'],
});
expect(res?.registryUrl).toBe('https://cci.internal.dev');
});
}); });
}); });
import { logger } from '../../../logger'; import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator'; import { cache } from '../../../util/cache/package/decorator';
import { joinUrlParts } from '../../../util/url';
import { Datasource } from '../datasource'; import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types'; import type { GetReleasesConfig, ReleaseResult } from '../types';
import type { OrbResponse } from './types'; import type { OrbResponse } from './types';
...@@ -27,9 +28,10 @@ export class OrbDatasource extends Datasource { ...@@ -27,9 +28,10 @@ export class OrbDatasource extends Datasource {
super(OrbDatasource.id); super(OrbDatasource.id);
} }
override readonly customRegistrySupport = false; override readonly customRegistrySupport = true;
override readonly defaultRegistryUrls = ['https://circleci.com/']; override readonly defaultRegistryUrls = ['https://circleci.com/'];
override readonly registryStrategy = 'hunt';
override readonly releaseTimestampSupport = true; override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote = override readonly releaseTimestampNote =
...@@ -47,7 +49,7 @@ export class OrbDatasource extends Datasource { ...@@ -47,7 +49,7 @@ export class OrbDatasource extends Datasource {
if (!registryUrl) { if (!registryUrl) {
return null; return null;
} }
const url = `${registryUrl}graphql-unstable`; const url = joinUrlParts(registryUrl, 'graphql-unstable');
const body = { const body = {
query, query,
variables: { packageName, maxVersions: MAX_VERSIONS }, variables: { packageName, maxVersions: MAX_VERSIONS },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment