Skip to content

Commit

Permalink
feat(datasource/orb): Add support for internal CircleCI Registries (#…
Browse files Browse the repository at this point in the history
…33213)

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
  • Loading branch information
mglazer and viceice authored Dec 20, 2024
1 parent 91c0483 commit 7eef0d3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`modules/datasource/orb/index getReleases processes homeUrl 1`] = `
{
"homepage": "https://google.com",
"isPrivate": false,
"registryUrl": "https://circleci.com/",
"registryUrl": "https://circleci.com",
"releases": [
{
"releaseTimestamp": "2018-12-11T05:28:14.080Z",
Expand Down Expand Up @@ -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",
"isPrivate": false,
"registryUrl": "https://circleci.com/",
"registryUrl": "https://circleci.com",
"releases": [
{
"releaseTimestamp": "2018-12-11T05:28:14.080Z",
Expand Down
13 changes: 13 additions & 0 deletions lib/modules/datasource/orb/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,18 @@ describe('modules/datasource/orb/index', () => {
expect(res).toMatchSnapshot();
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');
});
});
});
6 changes: 4 additions & 2 deletions lib/modules/datasource/orb/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { joinUrlParts } from '../../../util/url';
import { Datasource } from '../datasource';
import type { GetReleasesConfig, ReleaseResult } from '../types';
import type { OrbResponse } from './types';
Expand Down Expand Up @@ -27,9 +28,10 @@ export class OrbDatasource extends Datasource {
super(OrbDatasource.id);
}

override readonly customRegistrySupport = false;
override readonly customRegistrySupport = true;

override readonly defaultRegistryUrls = ['https://circleci.com/'];
override readonly registryStrategy = 'hunt';

override readonly releaseTimestampSupport = true;
override readonly releaseTimestampNote =
Expand All @@ -47,7 +49,7 @@ export class OrbDatasource extends Datasource {
if (!registryUrl) {
return null;
}
const url = `${registryUrl}graphql-unstable`;
const url = joinUrlParts(registryUrl, 'graphql-unstable');
const body = {
query,
variables: { packageName, maxVersions: MAX_VERSIONS },
Expand Down

0 comments on commit 7eef0d3

Please sign in to comment.