mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 15:36:25 +00:00
da73178171
Co-authored-by: Rhys Arkins <rhys@arkins.net>
35 lines
1 KiB
TypeScript
35 lines
1 KiB
TypeScript
import { logger } from '../../logger';
|
|
import { regEx } from '../../util/regex';
|
|
import * as dockerVersioning from '../../versioning/docker';
|
|
import { getDep } from '../dockerfile/extract';
|
|
import type { PackageDependency, PackageFile } from '../types';
|
|
|
|
export default function extractPackageFile(
|
|
content: string
|
|
): PackageFile | null {
|
|
logger.trace('ansible.extractPackageFile()');
|
|
let deps: PackageDependency[] = [];
|
|
const re = regEx(/^\s*image:\s*'?"?([^\s'"]+)'?"?\s*$/);
|
|
for (const line of content.split('\n')) {
|
|
const match = re.exec(line);
|
|
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.versioning = dockerVersioning.id;
|
|
deps.push(dep);
|
|
}
|
|
}
|
|
deps = deps.filter((dep) => !dep.currentValue?.includes('${'));
|
|
if (!deps.length) {
|
|
return null;
|
|
}
|
|
return { deps };
|
|
}
|