Skip to content

Commit

Permalink
fix(datasource/docker): map registry-1.docker.io to `index.docker.i…
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored and zT-1337 committed Jan 22, 2024
1 parent 459ac66 commit 14539dc
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/modules/datasource/docker/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ describe('modules/datasource/docker/common', () => {
registryHost: 'https://index.docker.io',
},
},
{
name: 'registry-1.docker.io/bitnamicharts/cert-manager',
url: 'https://index.docker.io',
res: {
dockerRepository: 'bitnamicharts/cert-manager',
registryHost: 'https://index.docker.io',
},
},
])('($name, $url)', ({ name, url, res }) => {
expect(getRegistryRepository(name, url)).toStrictEqual(res);
});
Expand Down
7 changes: 3 additions & 4 deletions lib/modules/datasource/docker/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,9 @@ export function getRegistryRepository(
dockerRepository = `${trimTrailingSlash(path)}/${dockerRepository}`;
}

registryHost = registryHost.replace(
'https://docker.io',
'https://index.docker.io',
);
registryHost = registryHost
.replace('https://docker.io', 'https://index.docker.io')
.replace('https://registry-1.docker.io', 'https://index.docker.io');

const opts = hostRules.find({
hostType: dockerDatasourceId,
Expand Down
41 changes: 41 additions & 0 deletions lib/modules/datasource/docker/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,47 @@ describe('modules/datasource/docker/index', () => {
});
});

it('Uses Docker Hub tags for registry-1.docker.io', async () => {
process.env.RENOVATE_X_DOCKER_HUB_TAGS = 'true';
httpMock
.scope(dockerHubUrl)
.get('/library/node/tags?page_size=1000')
.reply(200, {
next: `${dockerHubUrl}/library/node/tags?page=2&page_size=1000`,
results: [
{
name: '1.0.0',
tag_last_pushed: '2021-01-01T00:00:00.000Z',
digest: 'aaa',
},
],
})
.get('/library/node/tags?page=2&page_size=1000')
.reply(200, {
results: [
{
name: '0.9.0',
tag_last_pushed: '2020-01-01T00:00:00.000Z',
digest: 'bbb',
},
],
});
const res = await getPkgReleases({
datasource: DockerDatasource.id,
packageName: 'registry-1.docker.io/library/node',
});
expect(res?.releases).toMatchObject([
{
version: '0.9.0',
releaseTimestamp: '2020-01-01T00:00:00.000Z',
},
{
version: '1.0.0',
releaseTimestamp: '2021-01-01T00:00:00.000Z',
},
]);
});

it('adds library/ prefix for Docker Hub (implicit)', async () => {
process.env.RENOVATE_X_DOCKER_HUB_TAGS = 'true';
const tags = ['1.0.0'];
Expand Down

0 comments on commit 14539dc

Please sign in to comment.