renovate/lib/manager/ansible/extract.ts

37 lines
1 KiB
TypeScript

import { logger } from '../../logger';
import { getDep } from '../dockerfile/extract';
import { PackageFile, PackageDependency } from '../common';
export default function extractPackageFile(
content: string
): PackageFile | null {
logger.trace('ansible.extractPackageFile()');
let deps: PackageDependency[] = [];
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 dep = getDep(currentFrom);
logger.debug(
{
depName: dep.depName,
currentValue: dep.currentValue,
currentDigest: dep.currentDigest,
},
'Docker image inside ansible'
);
dep.managerData = { lineNumber };
dep.versionScheme = 'docker';
deps.push(dep);
}
lineNumber += 1;
}
deps = deps.filter(
dep => !(dep.currentValue && dep.currentValue.includes('${'))
);
if (!deps.length) {
return null;
}
return { deps };
}