renovate/lib/modules/manager/ansible/extract.ts
Benjamin Appel 551a40ccab
feat(manager/dockerfile): add support for registryAliases (#17139)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Niko Hass <nikohass571@gmail.com>
Co-authored-by: Niko Haß <48032410+nikohass@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-08-17 13:57:53 +00:00

37 lines
1.2 KiB
TypeScript

import { logger } from '../../../logger';
import { newlineRegex, regEx } from '../../../util/regex';
import * as dockerVersioning from '../../versioning/docker';
import { getDep } from '../dockerfile/extract';
import type { ExtractConfig, PackageDependency, PackageFile } from '../types';
export function extractPackageFile(
content: string,
_filename: string,
config: ExtractConfig
): PackageFile | null {
logger.trace('ansible.extractPackageFile()');
let deps: PackageDependency[] = [];
const re = regEx(/^\s*image:\s*'?"?([^\s'"]+)'?"?\s*$/);
for (const line of content.split(newlineRegex)) {
const match = re.exec(line);
if (match) {
const currentFrom = match[1];
const dep = getDep(currentFrom, true, config.registryAliases);
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 };
}