0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-12 06:09:06 +00:00
renovatebot_renovate/lib/modules/manager/terraform/lockfile/update-locked.ts
2023-11-07 15:50:29 +00:00

28 lines
992 B
TypeScript

import { logger } from '../../../../logger';
import { coerceString } from '../../../../util/string';
import type { UpdateLockedConfig, UpdateLockedResult } from '../../types';
import { extractLocks } from './util';
export function updateLockedDependency(
config: UpdateLockedConfig,
): UpdateLockedResult {
const { depName, currentVersion, newVersion, lockFile, lockFileContent } =
config;
// TODO: fix types (#22198)
logger.debug(
`terraform.updateLockedDependency: ${depName}@${currentVersion} -> ${newVersion} [${lockFile}]`,
);
try {
const locked = extractLocks(coerceString(lockFileContent));
const lockedDep = locked?.find(
(dep) => dep.packageName === coerceString(depName),
);
if (lockedDep?.version === newVersion) {
return { status: 'already-updated' };
}
return { status: 'unsupported' };
} catch (err) {
logger.debug({ err }, 'terraform.updateLockedDependency() error');
return { status: 'update-failed' };
}
}