renovate/lib/manager/droneci/extract.ts
2020-05-01 18:03:48 +02:00

34 lines
1 KiB
TypeScript

import { logger } from '../../logger';
import { PackageDependency, PackageFile } from '../common';
import { getDep } from '../dockerfile/extract';
export function extractPackageFile(content: string): PackageFile | null {
const deps: PackageDependency[] = [];
try {
const lines = content.split('\n');
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
const line = lines[lineNumber];
const match = /^\s* image:\s*'?"?([^\s'"]+)'?"?\s*$/.exec(line);
if (match) {
const currentFrom = match[1];
const dep = getDep(currentFrom);
logger.debug(
{
depName: dep.depName,
currentValue: dep.currentValue,
currentDigest: dep.currentDigest,
},
'DroneCI docker image'
);
dep.depType = 'docker';
deps.push(dep);
}
}
} catch (err) /* istanbul ignore next */ {
logger.warn({ err }, 'Error extracting DroneCI images');
}
if (!deps.length) {
return null;
}
return { deps };
}