Skip to content

Commit

Permalink
fix(docker): support nvcr.io tag listing (#17294)
Browse files Browse the repository at this point in the history
  • Loading branch information
steved committed Aug 21, 2022
1 parent 301f866 commit 7fb2e72
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
21 changes: 21 additions & 0 deletions lib/modules/datasource/docker/index.spec.ts
Expand Up @@ -545,6 +545,27 @@ describe('modules/datasource/docker/index', () => {
expect(res).toBe('some-digest');
});

it('supports token with no service', async () => {
httpMock
.scope(baseUrl)
.get('/')
.reply(401, '', {
'www-authenticate':
'Bearer realm="https://auth.docker.io/token",scope=""',
})
.head('/library/some-other-dep/manifests/8.0.0-alpine')
.reply(200, {}, { 'docker-content-digest': 'some-digest' });
httpMock
.scope(authUrl)
.get('/token?service=&scope=repository:library/some-other-dep:pull')
.reply(200, { access_token: 'test' });
const res = await getDigest(
{ datasource: 'docker', depName: 'some-other-dep' },
'8.0.0-alpine'
);
expect(res).toBe('some-digest');
});

it('supports scoped names', async () => {
httpMock
.scope(baseUrl)
Expand Down
7 changes: 5 additions & 2 deletions lib/modules/datasource/docker/index.ts
Expand Up @@ -140,7 +140,6 @@ export async function getAuthHeaders(
if (
authenticateHeader.scheme.toUpperCase() !== 'BEARER' ||
!is.string(authenticateHeader.params.realm) ||
!is.string(authenticateHeader.params.service) ||
parseUrl(authenticateHeader.params.realm) === null
) {
logger.trace(
Expand All @@ -159,7 +158,11 @@ export async function getAuthHeaders(
scope = authenticateHeader.params.scope;
}

const authUrl = `${authenticateHeader.params.realm}?service=${authenticateHeader.params.service}&scope=${scope}`;
let service = authenticateHeader.params.service;
if (!is.string(service)) {
service = '';
}
const authUrl = `${authenticateHeader.params.realm}?service=${service}&scope=${scope}`;
logger.trace(
{ registryHost, dockerRepository, authUrl },
`Obtaining docker registry token`
Expand Down

0 comments on commit 7fb2e72

Please sign in to comment.