refactor(circleci): use docker extract

This commit is contained in:
Rhys Arkins 2018-07-21 09:07:11 +02:00
parent 8a116f9ab5
commit 03b7bc40ff
2 changed files with 13 additions and 35 deletions

View file

@ -1,4 +1,4 @@
const { splitImageParts, getPurl } = require('../docker/extract'); const { getDep } = require('../docker/extract');
module.exports = { module.exports = {
extractDependencies, extractDependencies,
@ -12,39 +12,17 @@ function extractDependencies(content) {
const match = line.match(/^\s*- image:\s*'?"?([^\s'"]+)'?"?\s*$/); const match = line.match(/^\s*- image:\s*'?"?([^\s'"]+)'?"?\s*$/);
if (match) { if (match) {
const currentFrom = match[1]; const currentFrom = match[1];
const { const dep = getDep(currentFrom);
dockerRegistry,
depName,
currentTag,
currentDigest,
currentDepTagDigest,
currentDepTag,
currentValue,
tagSuffix,
} = splitImageParts(currentFrom);
logger.info( logger.info(
{ dockerRegistry, depName, currentTag, currentDigest }, {
dockerRegistry: dep.dockerRegistry,
depName: dep.depName,
currentTag: dep.currentTag,
currentDigest: dep.currentDigest,
},
'CircleCI docker image' 'CircleCI docker image'
); );
const purl = getPurl(dockerRegistry, depName, tagSuffix); dep.lineNumber = lineNumber;
const dep = {
lineNumber,
currentFrom,
fromVersion: currentFrom,
currentDepTagDigest,
dockerRegistry,
currentDepTag,
currentDigest,
depName,
currentTag,
currentValue,
tagSuffix,
purl,
versionScheme: 'docker',
};
if (depName === 'node' || depName.endsWith('/node')) {
dep.commitMessageTopic = 'Node.js';
}
deps.push(dep); deps.push(dep);
} }
lineNumber += 1; lineNumber += 1;

View file

@ -12,7 +12,7 @@ Array [
"currentValue": undefined, "currentValue": undefined,
"depName": "node", "depName": "node",
"dockerRegistry": undefined, "dockerRegistry": undefined,
"fromVersion": "node", "language": "docker",
"lineNumber": 12, "lineNumber": 12,
"purl": "pkg:docker/node", "purl": "pkg:docker/node",
"tagSuffix": undefined, "tagSuffix": undefined,
@ -28,7 +28,7 @@ Array [
"currentValue": "4", "currentValue": "4",
"depName": "node", "depName": "node",
"dockerRegistry": undefined, "dockerRegistry": undefined,
"fromVersion": "node:4", "language": "docker",
"lineNumber": 57, "lineNumber": 57,
"purl": "pkg:docker/node", "purl": "pkg:docker/node",
"tagSuffix": undefined, "tagSuffix": undefined,
@ -44,7 +44,7 @@ Array [
"currentValue": "6", "currentValue": "6",
"depName": "node", "depName": "node",
"dockerRegistry": undefined, "dockerRegistry": undefined,
"fromVersion": "node:6", "language": "docker",
"lineNumber": 61, "lineNumber": 61,
"purl": "pkg:docker/node", "purl": "pkg:docker/node",
"tagSuffix": undefined, "tagSuffix": undefined,
@ -60,7 +60,7 @@ Array [
"currentValue": "8.9.0", "currentValue": "8.9.0",
"depName": "node", "depName": "node",
"dockerRegistry": undefined, "dockerRegistry": undefined,
"fromVersion": "node:8.9.0", "language": "docker",
"lineNumber": 65, "lineNumber": 65,
"purl": "pkg:docker/node", "purl": "pkg:docker/node",
"tagSuffix": undefined, "tagSuffix": undefined,