Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config/inherit): resolve presets #31642

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 35 additions & 25 deletions lib/workers/repository/init/inherited.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
}
const inheritedConfig = parseResult.parsedContents as RenovateConfig;
logger.debug({ config: inheritedConfig }, `Inherited config`);
let res = await validateConfig('inherit', inheritedConfig);
const res = await validateConfig('inherit', inheritedConfig);
if (res.errors.length) {
logger.warn(
{ errors: res.errors },
Expand All @@ -102,33 +102,43 @@
);
}

const decryptedConfig = await decryptConfig(
filteredConfig,
if (is.nullOrUndefined(filteredConfig.extends)) {
return mergeChildConfig(config, filteredConfig);
}

let returnConfig = filteredConfig;

// Decrypt before resloving incase it contains npm authentication for any preset
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
const decryptedConfig = await decryptConfig(returnConfig, config.repository);

// Decrypt after resolving in case the preset contains npm authentication instead
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
logger.debug('Resolving presets found in inherited config');
const resolvedConfig = await decryptConfig(
await resolveConfigPresets(decryptedConfig, config, config.ignorePresets),
config.repository,
);
let returnConfig = decryptedConfig;
if (is.nonEmptyArray(returnConfig.extends)) {
// Decrypt after resolving in case the preset contains npm authentication instead
logger.debug('Resolving presets found in inherited config');
returnConfig = await decryptConfig(
await resolveConfigPresets(returnConfig, config, config.ignorePresets),
config.repository,
logger.trace({ config: resolvedConfig }, 'Resolved inherited config');
const validationRes = await validateConfig('inherit', resolvedConfig);
if (validationRes.errors.length) {
logger.warn(
{ errors: validationRes.errors },
'Found errors in presets inside the inherited configuration.',
);
throw new Error(CONFIG_VALIDATION);
}
if (validationRes.warnings.length) {
logger.warn(
{ warnings: validationRes.warnings },
'Found warnings in presets inside the inherited configuration.',
);
}

returnConfig = removeGlobalConfig(resolvedConfig, true);
if (!dequal(resolvedConfig, returnConfig)) {
logger.debug(

Check warning on line 138 in lib/workers/repository/init/inherited.ts

View check run for this annotation

Codecov / codecov/patch

lib/workers/repository/init/inherited.ts#L138

Added line #L138 was not covered by tests
{ resolvedConfig, returnConfig },
'Removed global config from inherited config presets.',
);
logger.trace({ config: returnConfig }, 'Resolved inherited config');
res = await validateConfig('inherit', returnConfig);
if (res.errors.length) {
logger.warn(
{ errors: res.errors },
'Found errors in presets inside the inherited configuration.',
);
throw new Error(CONFIG_VALIDATION);
}
if (res.warnings.length) {
logger.warn(
{ warnings: res.warnings },
'Found warnings in presets inside the inherited configuration.',
);
}
}

return mergeChildConfig(config, returnConfig);
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading