diff --git a/lib/manager/dockerfile/__snapshots__/extract.spec.ts.snap b/lib/manager/dockerfile/__snapshots__/extract.spec.ts.snap index 7b7696e59e5ab1eb86c206dc34ef9272a6526a2a..7d1c57f6c3e5996b8d3aa22f6771ecb1722c3e71 100644 --- a/lib/manager/dockerfile/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/dockerfile/__snapshots__/extract.spec.ts.snap @@ -346,6 +346,19 @@ Array [ ] `; +exports[`manager/dockerfile/extract extractPackageFile() handles quay hosts with port 1`] = ` +Object { + "autoReplaceStringTemplate": "{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}", + "currentDigest": undefined, + "currentValue": undefined, + "datasource": "docker", + "depName": "quay.io/node", + "depType": "final", + "lookupName": "quay.io:1234/node", + "replaceString": "quay.io:1234/node", +} +`; + exports[`manager/dockerfile/extract extractPackageFile() handles tag 1`] = ` Array [ Object { diff --git a/lib/manager/dockerfile/extract.spec.ts b/lib/manager/dockerfile/extract.spec.ts index 9d2bda92e9f199a016f0e4a3e94c974188736c45..96ebdcd718bbd2b19da125bcfe24c70213b0c28e 100644 --- a/lib/manager/dockerfile/extract.spec.ts +++ b/lib/manager/dockerfile/extract.spec.ts @@ -80,6 +80,15 @@ describe(getName(), () => { expect(res).toMatchSnapshot(); expect(res[0].depName).toEqual('registry2.something.info:5005/node'); }); + it('handles quay hosts with port', () => { + const res = extractPackageFile('FROM quay.io:1234/node\n').deps; + expect(res[0]).toMatchSnapshot({ + depName: 'quay.io/node', + lookupName: 'quay.io:1234/node', + autoReplaceStringTemplate: + '{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}', + }); + }); it('handles namespaced images', () => { const res = extractPackageFile('FROM mynamespace/node:8\n').deps; // FIXME: explicit assert condition diff --git a/lib/manager/dockerfile/extract.ts b/lib/manager/dockerfile/extract.ts index 7d8584e69b5442a560c8284f822fcfd8d1b3172a..a21cf10f9d16a8ab3315152f0ba0eea540df2047 100644 --- a/lib/manager/dockerfile/extract.ts +++ b/lib/manager/dockerfile/extract.ts @@ -32,6 +32,8 @@ export function splitImageParts(currentFrom: string): PackageDependency { return dep; } +const quayRegex = /^quay\.io(?::[1-9][0-9]{0,4})?/i; + export function getDep( currentFrom: string, specifyReplaceString = true @@ -63,6 +65,18 @@ export function getDep( if (dep.depName === 'ubuntu') { dep.versioning = ubuntuVersioning.id; } + + // Don't display quay.io ports + if (quayRegex.test(dep.depName)) { + const depName = dep.depName.replace(quayRegex, 'quay.io'); + if (depName !== dep.depName) { + dep.lookupName = dep.depName; + dep.depName = depName; + dep.autoReplaceStringTemplate = + '{{lookupName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}'; + } + } + return dep; }