mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
34 lines
1 KiB
TypeScript
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 };
|
|
}
|