From 7eef0d3ed0acd1c67224c55b87395df06bde9753 Mon Sep 17 00:00:00 2001 From: Mike Glazer Date: Fri, 20 Dec 2024 08:07:28 -0800 Subject: feat(datasource/orb): Add support for internal CircleCI Registries (#33213) Co-authored-by: Michael Kriese --- lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap | 4 ++-- lib/modules/datasource/orb/index.spec.ts | 13 +++++++++++++ lib/modules/datasource/orb/index.ts | 6 ++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap index b3583fe0121..b6f16507953 100644 --- a/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/orb/__snapshots__/index.spec.ts.snap @@ -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", @@ -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", diff --git a/lib/modules/datasource/orb/index.spec.ts b/lib/modules/datasource/orb/index.spec.ts index e2dd13dd7b8..1cb1e8519d4 100644 --- a/lib/modules/datasource/orb/index.spec.ts +++ b/lib/modules/datasource/orb/index.spec.ts @@ -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'); + }); }); }); diff --git a/lib/modules/datasource/orb/index.ts b/lib/modules/datasource/orb/index.ts index 12e3bc834d5..80fa61e4e93 100644 --- a/lib/modules/datasource/orb/index.ts +++ b/lib/modules/datasource/orb/index.ts @@ -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'; @@ -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 = @@ -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 }, -- cgit v1.2.3