diff --git a/lib/datasource/docker/__snapshots__/index.spec.ts.snap b/lib/datasource/docker/__snapshots__/index.spec.ts.snap index 84626fcb481d6681d9551a32632c19089bfc97c1..abba07ed47c4cb62255bb4951c494105f8fc9138 100644 --- a/lib/datasource/docker/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/docker/__snapshots__/index.spec.ts.snap @@ -7,6 +7,13 @@ Object { } `; +exports[`api/docker getRegistryRepository supports registryUrls 1`] = ` +Object { + "registry": "my.local.registry/prefix/", + "repository": "image", +} +`; + exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1`] = ` [MockFunction] { "calls": Array [ diff --git a/lib/datasource/docker/index.spec.ts b/lib/datasource/docker/index.spec.ts index e6eaa4628d79ecb2c1c3d967a8cf19b7bead872a..24909e0b8549e94332269de2093e7f62efb8e8e2 100644 --- a/lib/datasource/docker/index.spec.ts +++ b/lib/datasource/docker/index.spec.ts @@ -18,6 +18,13 @@ describe('api/docker', () => { const res = docker.getRegistryRepository('registry:5000/org/package', []); expect(res).toMatchSnapshot(); }); + it('supports registryUrls', () => { + const res = docker.getRegistryRepository( + 'my.local.registry/prefix/image', + ['https://my.local.registry/prefix'] + ); + expect(res).toMatchSnapshot(); + }); }); describe('getDigest', () => { beforeEach(() => { diff --git a/lib/datasource/docker/index.ts b/lib/datasource/docker/index.ts index 9af8dec5203cd807df27ac2f903d8ee535fe23f6..bd6906f5489daa7935a4914d5bc6f6830f5a4567 100644 --- a/lib/datasource/docker/index.ts +++ b/lib/datasource/docker/index.ts @@ -60,6 +60,17 @@ export function getRegistryRepository( lookupName: string, registryUrls: string[] ): RegistryRepository { + if (is.nonEmptyArray(registryUrls)) { + const dockerRegistry = registryUrls[0] + .replace('https://', '') + .replace(/\/?$/, '/'); + if (lookupName.startsWith(dockerRegistry)) { + return { + registry: dockerRegistry, + repository: lookupName.replace(dockerRegistry, ''), + }; + } + } let registry: string; const split = lookupName.split('/'); if (split.length > 1 && (split[0].includes('.') || split[0].includes(':'))) {