Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/docker): accept key-only arguments in COPY --from #31344

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/modules/manager/dockerfile/extract.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import type { PackageDependency } from '../types';
import { extractVariables, getDep } from './extract';
Expand Down Expand Up @@ -395,6 +396,31 @@ describe('modules/manager/dockerfile/extract', () => {
]);
});

it('handles COPY --link --from', () => {
const res = extractPackageFile(
codeBlock`
FROM scratch
COPY --link --from=gcr.io/k8s-skaffold/skaffold:v0.11.0 /usr/bin/skaffold /usr/bin/skaffold
`,
'',
{},
);
expect(res).toEqual({
deps: [
{
autoReplaceStringTemplate:
'{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: 'v0.11.0',
datasource: 'docker',
depName: 'gcr.io/k8s-skaffold/skaffold',
depType: 'final',
replaceString: 'gcr.io/k8s-skaffold/skaffold:v0.11.0',
},
],
});
});

it('skips named multistage COPY --from tags', () => {
const res = extractPackageFile(
'FROM node:6.12.3 as frontend\n\n# comment\nENV foo=bar\nCOPY --from=frontend /usr/bin/node /usr/bin/node\n',
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/dockerfile/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export function extractPackageFile(
const copyFromRegex = new RegExp(
'^[ \\t]*COPY(?:' +
escapeChar +
'[ \\t]*\\r?\\n| |\\t|#.*?\\r?\\n|--[a-z]+=[a-zA-Z0-9_.:-]+?)+--from=(?<image>\\S+)',
'[ \\t]*\\r?\\n| |\\t|#.*?\\r?\\n|--[a-z]+(?:=[a-zA-Z0-9_.:-]+?)?)+--from=(?<image>\\S+)',
'im',
); // TODO #12875 complex for re2 has too many not supported groups
const copyFromMatch = instruction.match(copyFromRegex);
Expand Down