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 = {
extractDependencies,
@ -12,39 +12,17 @@ function extractDependencies(content) {
const match = line.match(/^\s*- image:\s*'?"?([^\s'"]+)'?"?\s*$/);
if (match) {
const currentFrom = match[1];
const {
dockerRegistry,
depName,
currentTag,
currentDigest,
currentDepTagDigest,
currentDepTag,
currentValue,
tagSuffix,
} = splitImageParts(currentFrom);
const dep = getDep(currentFrom);
logger.info(
{ dockerRegistry, depName, currentTag, currentDigest },
{
dockerRegistry: dep.dockerRegistry,
depName: dep.depName,
currentTag: dep.currentTag,
currentDigest: dep.currentDigest,
},
'CircleCI docker image'
);
const purl = getPurl(dockerRegistry, depName, tagSuffix);
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';
}
dep.lineNumber = lineNumber;
deps.push(dep);
}
lineNumber += 1;

View file

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