Skip to content
Snippets Groups Projects
Unverified Commit 6cc2e501 authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

fix: reduce code issues (#8639)

parent 1a9e5434
No related branches found
No related tags found
No related merge requests found
...@@ -21,23 +21,13 @@ FROM\ ...@@ -21,23 +21,13 @@ FROM\
COPY --from=image6 /path/1 /path/2 COPY --from=image6 /path/1 /path/2
COPY \ COPY \
# comment1
--from=image7:1.0.0@sha256:abcdef \ --from=image7:1.0.0@sha256:abcdef \
/path/1 \ /path/1 \
/path/2 /path/2
# COPY --from=image8 # COPY --from=image8
COPY --from=image9
COPY\
--chown=root \
# comment1
#
#comment2
--from=image10
# comment2
path1 path2
COPY --chown=root --from=image11 / ./ COPY --chown=root --from=image11 / ./
COPY \ COPY \
......
...@@ -89,24 +89,6 @@ Array [ ...@@ -89,24 +89,6 @@ Array [
"depType": "stage", "depType": "stage",
"replaceString": "image7:1.0.0@sha256:abcdef", "replaceString": "image7:1.0.0@sha256:abcdef",
}, },
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": undefined,
"datasource": "docker",
"depName": "image9",
"depType": "stage",
"replaceString": "image9",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": undefined,
"datasource": "docker",
"depName": "image10",
"depType": "stage",
"replaceString": "image10",
},
Object { Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}", "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined, "currentDigest": undefined,
......
...@@ -2,12 +2,12 @@ import { readFileSync } from 'fs'; ...@@ -2,12 +2,12 @@ import { readFileSync } from 'fs';
import { extractPackageFile, getDep } from './extract'; import { extractPackageFile, getDep } from './extract';
const d1 = readFileSync( const d1 = readFileSync(
'lib/manager/dockerfile/__fixtures__/Dockerfile1', 'lib/manager/dockerfile/__fixtures__/1.Dockerfile',
'utf8' 'utf8'
); );
const d2 = readFileSync( const d2 = readFileSync(
'lib/manager/dockerfile/__fixtures__/Dockerfile2', 'lib/manager/dockerfile/__fixtures__/2.Dockerfile',
'utf8' 'utf8'
); );
...@@ -150,7 +150,7 @@ describe('lib/manager/dockerfile/extract', () => { ...@@ -150,7 +150,7 @@ describe('lib/manager/dockerfile/extract', () => {
it('extracts images from all sorts of (maybe multiline) FROM and COPY --from statements', () => { it('extracts images from all sorts of (maybe multiline) FROM and COPY --from statements', () => {
const res = extractPackageFile(d2).deps; const res = extractPackageFile(d2).deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(11); expect(res).toHaveLength(9);
}); });
it('handles calico/node', () => { it('handles calico/node', () => {
const res = extractPackageFile('FROM calico/node\n').deps; const res = extractPackageFile('FROM calico/node\n').deps;
......
...@@ -67,7 +67,7 @@ export function extractPackageFile(content: string): PackageFile | null { ...@@ -67,7 +67,7 @@ export function extractPackageFile(content: string): PackageFile | null {
const stageNames: string[] = []; const stageNames: string[] = [];
const fromMatches = content.matchAll( const fromMatches = content.matchAll(
/^[ \t]*FROM(?:\\\r?\n| |\t|#.*\r?\n|-\S+)+(?<image>\S+)(?:(?:\\\r?\n| |\t|#.*\r?\n)+as[ \t]+(?<name>\S+))?/gim /^[ \t]*FROM(?:\\\r?\n| |\t|#.*?\r?\n|[ \t]--[a-z]+=\w+?)*[ \t](?<image>\S+)(?:(?:\\\r?\n| |\t|#.*\r?\n)+as[ \t]+(?<name>\S+))?/gim
); );
for (const fromMatch of fromMatches) { for (const fromMatch of fromMatches) {
...@@ -94,7 +94,7 @@ export function extractPackageFile(content: string): PackageFile | null { ...@@ -94,7 +94,7 @@ export function extractPackageFile(content: string): PackageFile | null {
} }
const copyFromMatches = content.matchAll( const copyFromMatches = content.matchAll(
/^[ \t]*COPY(?:\\\r?\n| |\t|#.*\r?\n|-\S+)+--from=(?<image>\S+)/gim /^[ \t]*COPY(?:\\\r?\n| |\t|#.*\r?\n|[ \t]--[a-z]+=\w+?)*[ \t]--from=(?<image>\S+)/gim
); );
for (const copyFromMatch of copyFromMatches) { for (const copyFromMatch of copyFromMatches) {
......
...@@ -42,6 +42,7 @@ describe('manager/gradle-lite/utils', () => { ...@@ -42,6 +42,7 @@ describe('manager/gradle-lite/utils', () => {
expect(isDependencyString("foo:bar:1.2.3'")).toBe(false); expect(isDependencyString("foo:bar:1.2.3'")).toBe(false);
expect(isDependencyString('foo:bar:1.2.3"')).toBe(false); expect(isDependencyString('foo:bar:1.2.3"')).toBe(false);
expect(isDependencyString('-Xep:ParameterName:OFF')).toBe(false); expect(isDependencyString('-Xep:ParameterName:OFF')).toBe(false);
expect(isDependencyString('foo$bar:baz:1.2.+')).toBe(false);
}); });
it('parseDependencyString', () => { it('parseDependencyString', () => {
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
} from './common'; } from './common';
const artifactRegex = regEx( const artifactRegex = regEx(
'^[a-zA-Z][-_a-zA-Z0-9]*(?:.[a-zA-Z0-9][-_a-zA-Z0-9]*)*$' '^[a-zA-Z][-_a-zA-Z0-9]*(?:\\.[a-zA-Z0-9][-_a-zA-Z0-9]*?)*$'
); );
const versionLikeRegex = regEx('^(?<version>[-.\\[\\](),a-zA-Z0-9+]+)'); const versionLikeRegex = regEx('^(?<version>[-.\\[\\](),a-zA-Z0-9+]+)');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment