renovate/lib/manager/circleci/extract.js
Rhys Arkins 7254b5f16c
feat: use generic lookup for docker (#2280)
Removes custom Docker lookup code and instead integrates it with the generic lookup routine used by other package managers. Logic for digest support was added but is used by Docker-only for now.

Closes #2081, Closes #2276
2018-07-20 09:09:01 +02:00

56 lines
1.4 KiB
JavaScript

const { splitImageParts, getPurl } = require('../docker/extract');
module.exports = {
extractDependencies,
};
function extractDependencies(content) {
logger.debug('circleci.extractDependencies()');
const deps = [];
let lineNumber = 0;
for (const line of content.split('\n')) {
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);
logger.info(
{ dockerRegistry, depName, currentTag, 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';
}
deps.push(dep);
}
lineNumber += 1;
}
if (!deps.length) {
return null;
}
return { deps };
}