-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
9d1a597
6208ad1
9e2f462
a52e9b9
140a794
2fff2f1
2a932d5
712f3d7
b01e062
139fced
716c1a6
d697f48
8786fba
e871e4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -155,7 +155,18 @@ | |||||||||
|
||||||||||
For information on how the Mend Renovate App supports Inherited config, see the dedicated "Mend Renovate App Config" section toward the end of this page. | ||||||||||
|
||||||||||
#### Presets handling | ||||||||||
|
||||||||||
If the inherited config has presets, then Renovate: | ||||||||||
|
||||||||||
1. Resolves the presets | ||||||||||
1. Adds the resolved presets to the inherited config | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Maybe this is better. If we go with |
||||||||||
1. Merges the presets on top of the global config | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
##### You can not ignore presets from inherited config | ||||||||||
rarkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
You can _not_ use `ignorePresets` in your repository config to ignore presets _within_ inherited config. | ||||||||||
This is because inherited config is resolved _before_ the repository config. | ||||||||||
|
||||||||||
Check failure on line 168 in docs/usage/config-overview.md GitHub Actions / lint-docsLists should be surrounded by blank lines
|
||||||||||
### Repository config | ||||||||||
Check failure on line 169 in docs/usage/config-overview.md GitHub Actions / lint-docsHeadings should be surrounded by blank lines
Check failure on line 169 in docs/usage/config-overview.md GitHub Actions / lint-docsHeadings should be surrounded by blank lines
|
||||||||||
|
||||||||||
Repository config is the config loaded from a config file in the repository. | ||||||||||
Alternative file names are supported, but the default is `renovate.json`. | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import is from '@sindresorhus/is'; | ||
import { dequal } from 'dequal'; | ||
import { mergeChildConfig, removeGlobalConfig } from '../../../config'; | ||
import { decryptConfig } from '../../../config/decrypt'; | ||
import { parseFileConfig } from '../../../config/parse'; | ||
import { resolveConfigPresets } from '../../../config/presets'; | ||
import type { RenovateConfig } from '../../../config/types'; | ||
import { validateConfig } from '../../../config/validation'; | ||
import { | ||
|
@@ -99,5 +101,45 @@ export async function mergeInheritedConfig( | |
'Removed global config from inherited config.', | ||
); | ||
} | ||
return mergeChildConfig(config, filteredConfig); | ||
|
||
if (is.nullOrUndefined(filteredConfig.extends)) { | ||
return mergeChildConfig(config, filteredConfig); | ||
} | ||
|
||
let returnConfig = filteredConfig; | ||
|
||
// Decrypt before resolving, in case 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 | ||
logger.debug('Resolving presets found in inherited config'); | ||
const resolvedConfig = await decryptConfig( | ||
await resolveConfigPresets(decryptedConfig, 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( | ||
{ inheritedConfig: resolvedConfig, filteredConfig: returnConfig }, | ||
'Removed global config from inherited config presets.', | ||
); | ||
Comment on lines
+133
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inherited config does allow some fields which were previously considered "global", such as |
||
} | ||
|
||
return mergeChildConfig(config, returnConfig); | ||
RahulGautamSingh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.