Skip to content

Commit

Permalink
fix(dockerfile): handle codenames with registries
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunet committed May 8, 2024
1 parent 4eaa0c5 commit 974127b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions lib/modules/manager/dockerfile/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,23 @@ describe('modules/manager/dockerfile/extract', () => {
]);
});

it('handles debian with prefixes and registries', () => {
const res = extractPackageFile('FROM docker.io/library/debian:10\n', '', {})?.deps;
expect(res).toEqual([
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: '10',
datasource: 'docker',
depName: 'docker.io/library/debian',
depType: 'final',
replaceString: 'docker.io/library/debian:10',
versioning: 'debian',
},
]);
});

it('handles prefixes', () => {
const res = extractPackageFile('FROM amd64/ubuntu:18.04\n', '', {})?.deps;
expect(res).toEqual([
Expand All @@ -687,6 +704,23 @@ describe('modules/manager/dockerfile/extract', () => {
]);
});

it('handles prefixes with registries', () => {
const res = extractPackageFile('FROM public.ecr.aws/ubuntu/ubuntu:18.04\n', '', {})?.deps;
expect(res).toEqual([
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: '18.04',
datasource: 'docker',
depName: "public.ecr.aws/ubuntu/ubuntu",
depType: 'final',
replaceString: "public.ecr.aws/ubuntu/ubuntu:18.04",
versioning: 'ubuntu',
},
]);
});

it('handles implausible line continuation', () => {
const res = extractPackageFile(
'FROM alpine:3.5\n\nRUN something \\',
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/dockerfile/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ export function getDep(
}
}

if (dep.depName === 'ubuntu') {
if (dep.depName === 'ubuntu' || dep.depName?.endsWith('/ubuntu')) {
dep.versioning = ubuntuVersioning.id;
}

if (
dep.depName === 'debian' &&
(dep.depName === 'debian' || dep.depName?.endsWith('/debian')) &&
debianVersioning.api.isVersion(dep.currentValue)
) {
dep.versioning = debianVersioning.id;
Expand Down

0 comments on commit 974127b

Please sign in to comment.