refactor: config option parent -> parents (#26609)

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
This commit is contained in:
RahulGautamSingh 2024-01-22 14:08:59 +05:45 committed by GitHub
parent 979358c2d5
commit d908ca3c2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 105 additions and 97 deletions

View file

@ -259,7 +259,7 @@ exports[`config/validation validateConfig(config) validates regEx for each fileM
exports[`config/validation validateConfig(config) warns if hostType has the wrong parent 1`] = ` exports[`config/validation validateConfig(config) warns if hostType has the wrong parent 1`] = `
[ [
{ {
"message": "hostType should only be configured within a "hostRules" object. Was found in .", "message": "hostType should only be configured within one of "hostRules" objects. Was found in .",
"topic": "hostType", "topic": "hostType",
}, },
] ]

View file

@ -23,7 +23,7 @@ export function getConfig(): AllConfig {
const options = getOptions(); const options = getOptions();
const config: AllConfig = {}; const config: AllConfig = {};
options.forEach((option) => { options.forEach((option) => {
if (!option.parent) { if (!option.parents) {
config[option.name] = getDefault(option); config[option.name] = getDefault(option);
} }
}); });

View file

@ -72,7 +72,7 @@ const options: RenovateOptions[] = [
'A list of post-upgrade commands that are executed before a commit is made by Renovate.', 'A list of post-upgrade commands that are executed before a commit is made by Renovate.',
type: 'array', type: 'array',
subType: 'string', subType: 'string',
parent: 'postUpgradeTasks', parents: ['postUpgradeTasks'],
default: [], default: [],
cli: false, cli: false,
}, },
@ -82,7 +82,7 @@ const options: RenovateOptions[] = [
'Files that match the glob pattern will be committed after running a post-upgrade task.', 'Files that match the glob pattern will be committed after running a post-upgrade task.',
type: 'array', type: 'array',
subType: 'string', subType: 'string',
parent: 'postUpgradeTasks', parents: ['postUpgradeTasks'],
default: ['**/*'], default: ['**/*'],
cli: false, cli: false,
}, },
@ -90,7 +90,7 @@ const options: RenovateOptions[] = [
name: 'format', name: 'format',
description: 'Format of the custom datasource.', description: 'Format of the custom datasource.',
type: 'string', type: 'string',
parent: 'customDatasources', parents: ['customDatasources'],
default: 'json', default: 'json',
allowedValues: ['json', 'plain'], allowedValues: ['json', 'plain'],
cli: false, cli: false,
@ -101,7 +101,7 @@ const options: RenovateOptions[] = [
description: description:
'Controls when the post upgrade tasks run: on every update, or once per upgrade branch.', 'Controls when the post upgrade tasks run: on every update, or once per upgrade branch.',
type: 'string', type: 'string',
parent: 'postUpgradeTasks', parents: ['postUpgradeTasks'],
allowedValues: ['update', 'branch'], allowedValues: ['update', 'branch'],
default: 'update', default: 'update',
cli: false, cli: false,
@ -1012,7 +1012,7 @@ const options: RenovateOptions[] = [
'Template for generating a `defaultRegistryUrl` for custom datasource.', 'Template for generating a `defaultRegistryUrl` for custom datasource.',
type: 'string', type: 'string',
default: '', default: '',
parent: 'customDatasources', parents: ['customDatasources'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1099,7 +1099,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
allowString: true, allowString: true,
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
mergeable: true, mergeable: true,
cli: false, cli: false,
@ -1113,7 +1113,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1126,7 +1126,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1138,7 +1138,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
allowString: true, allowString: true,
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
mergeable: true, mergeable: true,
cli: false, cli: false,
@ -1151,7 +1151,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
allowString: true, allowString: true,
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
mergeable: true, mergeable: true,
cli: false, cli: false,
@ -1164,7 +1164,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
allowString: true, allowString: true,
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
mergeable: true, mergeable: true,
cli: false, cli: false,
@ -1177,7 +1177,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
allowString: true, allowString: true,
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
mergeable: true, mergeable: true,
cli: false, cli: false,
@ -1191,7 +1191,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1204,7 +1204,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1217,7 +1217,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1231,7 +1231,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1245,7 +1245,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1258,7 +1258,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1272,7 +1272,7 @@ const options: RenovateOptions[] = [
format: 'regex', format: 'regex',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1286,7 +1286,7 @@ const options: RenovateOptions[] = [
format: 'regex', format: 'regex',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1300,7 +1300,7 @@ const options: RenovateOptions[] = [
format: 'regex', format: 'regex',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1315,7 +1315,7 @@ const options: RenovateOptions[] = [
format: 'regex', format: 'regex',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1327,7 +1327,7 @@ const options: RenovateOptions[] = [
'A regex to match against the raw `currentValue` string of a dependency. Valid only within a `packageRules` object.', 'A regex to match against the raw `currentValue` string of a dependency. Valid only within a `packageRules` object.',
type: 'string', type: 'string',
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1338,7 +1338,7 @@ const options: RenovateOptions[] = [
'A version, or range of versions, to match against the current version of a package. Valid only within a `packageRules` object.', 'A version, or range of versions, to match against the current version of a package. Valid only within a `packageRules` object.',
type: 'string', type: 'string',
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1351,7 +1351,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1363,7 +1363,7 @@ const options: RenovateOptions[] = [
subType: 'string', subType: 'string',
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1381,7 +1381,7 @@ const options: RenovateOptions[] = [
'The name of the new dependency that replaces the old deprecated dependency.', 'The name of the new dependency that replaces the old deprecated dependency.',
type: 'string', type: 'string',
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1391,7 +1391,7 @@ const options: RenovateOptions[] = [
type: 'string', type: 'string',
default: '{{{packageName}}}', default: '{{{packageName}}}',
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1401,7 +1401,7 @@ const options: RenovateOptions[] = [
'The version of the new dependency that replaces the old deprecated dependency.', 'The version of the new dependency that replaces the old deprecated dependency.',
type: 'string', type: 'string',
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1414,7 +1414,7 @@ const options: RenovateOptions[] = [
allowedValues: ['low', 'neutral', 'high', 'very high'], allowedValues: ['low', 'neutral', 'high', 'very high'],
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1440,7 +1440,7 @@ const options: RenovateOptions[] = [
], ],
allowString: true, allowString: true,
stage: 'package', stage: 'package',
parent: 'packageRules', parents: ['packageRules'],
mergeable: true, mergeable: true,
cli: false, cli: false,
env: false, env: false,
@ -1452,7 +1452,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
stage: 'repository', stage: 'repository',
parent: 'packageRules', parents: ['packageRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1462,7 +1462,7 @@ const options: RenovateOptions[] = [
description: description:
'A version range or regex pattern capturing allowed versions for dependencies.', 'A version range or regex pattern capturing allowed versions for dependencies.',
type: 'string', type: 'string',
parent: 'packageRules', parents: ['packageRules'],
stage: 'package', stage: 'package',
cli: false, cli: false,
env: false, env: false,
@ -1473,7 +1473,7 @@ const options: RenovateOptions[] = [
'If set, Renovate will use this URL to fetch changelogs for a matched dependency. Valid only within a `packageRules` object.', 'If set, Renovate will use this URL to fetch changelogs for a matched dependency. Valid only within a `packageRules` object.',
type: 'string', type: 'string',
stage: 'pr', stage: 'pr',
parent: 'packageRules', parents: ['packageRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -1872,7 +1872,7 @@ const options: RenovateOptions[] = [
description: 'List of jsonata transformation rules.', description: 'List of jsonata transformation rules.',
type: 'array', type: 'array',
subType: 'string', subType: 'string',
parent: 'customDatasources', parents: ['customDatasources'],
default: [], default: [],
}, },
{ {
@ -2286,7 +2286,7 @@ const options: RenovateOptions[] = [
'hostType for a package rule. Can be a platform name or a datasource name.', 'hostType for a package rule. Can be a platform name or a datasource name.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2295,7 +2295,7 @@ const options: RenovateOptions[] = [
description: 'A domain name, host name or base URL to match against.', description: 'A domain name, host name or base URL to match against.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2304,7 +2304,7 @@ const options: RenovateOptions[] = [
description: 'Timeout (in milliseconds) for queries to external endpoints.', description: 'Timeout (in milliseconds) for queries to external endpoints.',
type: 'integer', type: 'integer',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2313,7 +2313,7 @@ const options: RenovateOptions[] = [
description: 'Explicitly turn on insecure Docker registry access (HTTP).', description: 'Explicitly turn on insecure Docker registry access (HTTP).',
type: 'boolean', type: 'boolean',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
advancedUse: true, advancedUse: true,
@ -2324,7 +2324,7 @@ const options: RenovateOptions[] = [
'If enabled, Renovate aborts its run when HTTP request errors occur.', 'If enabled, Renovate aborts its run when HTTP request errors occur.',
type: 'boolean', type: 'boolean',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: false, default: false,
cli: false, cli: false,
env: false, env: false,
@ -2336,7 +2336,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'number', subType: 'number',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2345,7 +2345,7 @@ const options: RenovateOptions[] = [
description: 'Enable got HTTP/2 support.', description: 'Enable got HTTP/2 support.',
type: 'boolean', type: 'boolean',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: false, default: false,
cli: false, cli: false,
env: false, env: false,
@ -2355,7 +2355,7 @@ const options: RenovateOptions[] = [
description: 'Limit concurrent requests per host.', description: 'Limit concurrent requests per host.',
type: 'integer', type: 'integer',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: null, default: null,
cli: false, cli: false,
env: false, env: false,
@ -2365,7 +2365,7 @@ const options: RenovateOptions[] = [
description: 'Limit requests rate per host.', description: 'Limit requests rate per host.',
type: 'integer', type: 'integer',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: 0, default: 0,
cli: false, cli: false,
env: false, env: false,
@ -2376,7 +2376,7 @@ const options: RenovateOptions[] = [
'Authentication type for HTTP header. e.g. `"Bearer"` or `"Basic"`. Use `"Token-Only"` to use only the token without an authorization type.', 'Authentication type for HTTP header. e.g. `"Bearer"` or `"Basic"`. Use `"Token-Only"` to use only the token without an authorization type.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: 'Bearer', default: 'Bearer',
cli: false, cli: false,
env: false, env: false,
@ -2386,7 +2386,7 @@ const options: RenovateOptions[] = [
description: 'Enable got DNS cache.', description: 'Enable got DNS cache.',
type: 'boolean', type: 'boolean',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: false, default: false,
cli: false, cli: false,
env: false, env: false,
@ -2397,7 +2397,7 @@ const options: RenovateOptions[] = [
description: 'Enable HTTP keep-alive for hosts.', description: 'Enable HTTP keep-alive for hosts.',
type: 'boolean', type: 'boolean',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: false, default: false,
cli: false, cli: false,
env: false, env: false,
@ -2408,7 +2408,7 @@ const options: RenovateOptions[] = [
description: description:
'Put fields to be forwarded to the HTTP request headers in the headers config option.', 'Put fields to be forwarded to the HTTP request headers in the headers config option.',
type: 'object', type: 'object',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
advancedUse: true, advancedUse: true,
@ -2421,7 +2421,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
allowedValues: ['composer'], allowedValues: ['composer'],
default: null, default: null,
cli: false, cli: false,
@ -2432,7 +2432,7 @@ const options: RenovateOptions[] = [
description: 'The overriding trusted CA certificate.', description: 'The overriding trusted CA certificate.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: null, default: null,
cli: false, cli: false,
env: false, env: false,
@ -2442,7 +2442,7 @@ const options: RenovateOptions[] = [
description: 'The private key in PEM format.', description: 'The private key in PEM format.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: null, default: null,
cli: false, cli: false,
env: false, env: false,
@ -2452,7 +2452,7 @@ const options: RenovateOptions[] = [
description: 'The certificate chains in PEM format.', description: 'The certificate chains in PEM format.',
type: 'string', type: 'string',
stage: 'repository', stage: 'repository',
parent: 'hostRules', parents: ['hostRules'],
default: null, default: null,
cli: false, cli: false,
env: false, env: false,
@ -2576,7 +2576,7 @@ const options: RenovateOptions[] = [
'Custom manager to use. Valid only within a `customManagers` object.', 'Custom manager to use. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
allowedValues: ['regex'], allowedValues: ['regex'],
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2587,7 +2587,7 @@ const options: RenovateOptions[] = [
type: 'array', type: 'array',
subType: 'string', subType: 'string',
format: 'regex', format: 'regex',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2597,7 +2597,7 @@ const options: RenovateOptions[] = [
type: 'string', type: 'string',
default: 'any', default: 'any',
allowedValues: ['any', 'recursive', 'combination'], allowedValues: ['any', 'recursive', 'combination'],
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2606,7 +2606,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional depName for extracted dependencies. Valid only within a `customManagers` object.', 'Optional depName for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2615,7 +2615,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional packageName for extracted dependencies, else defaults to `depName` value. Valid only within a `customManagers` object.', 'Optional packageName for extracted dependencies, else defaults to `depName` value. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2624,7 +2624,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional datasource for extracted dependencies. Valid only within a `customManagers` object.', 'Optional datasource for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2633,7 +2633,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional `depType` for extracted dependencies. Valid only within a `customManagers` object.', 'Optional `depType` for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2642,7 +2642,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional `currentValue` for extracted dependencies. Valid only within a `customManagers` object.', 'Optional `currentValue` for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2651,7 +2651,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional versioning for extracted dependencies. Valid only within a `customManagers` object.', 'Optional versioning for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2660,7 +2660,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional registry URL for extracted dependencies. Valid only within a `customManagers` object.', 'Optional registry URL for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2669,7 +2669,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional `extractVersion` for extracted dependencies. Valid only within a `customManagers` object.', 'Optional `extractVersion` for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2678,7 +2678,7 @@ const options: RenovateOptions[] = [
description: description:
'Optional `extractVersion` for extracted dependencies. Valid only within a `customManagers` object.', 'Optional `extractVersion` for extracted dependencies. Valid only within a `customManagers` object.',
type: 'string', type: 'string',
parent: 'customManagers', parents: ['customManagers'],
cli: false, cli: false,
env: false, env: false,
}, },
@ -2795,7 +2795,7 @@ const options: RenovateOptions[] = [
type: 'integer', type: 'integer',
default: 60, default: 60,
stage: 'package', stage: 'package',
parent: 'hostRules', parents: ['hostRules'],
cli: false, cli: false,
env: false, env: false,
}, },

View file

@ -368,6 +368,12 @@ export interface ValidationMessage {
message: string; message: string;
} }
export type AllowedParents =
| 'customManagers'
| 'customDatasources'
| 'hostRules'
| 'postUpgradeTasks'
| 'packageRules';
export interface RenovateOptionBase { export interface RenovateOptionBase {
/** /**
* If true, the option can only be configured by people with access to the Renovate instance. * If true, the option can only be configured by people with access to the Renovate instance.
@ -396,12 +402,7 @@ export interface RenovateOptionBase {
name: string; name: string;
parent?: parents?: AllowedParents[];
| 'customDatasources'
| 'hostRules'
| 'packageRules'
| 'postUpgradeTasks'
| 'customManagers';
stage?: RenovateConfigStage; stage?: RenovateConfigStage;

View file

@ -20,6 +20,7 @@ import { migrateConfig } from './migration';
import { getOptions } from './options'; import { getOptions } from './options';
import { resolveConfigPresets } from './presets'; import { resolveConfigPresets } from './presets';
import { import {
AllowedParents,
type RenovateConfig, type RenovateConfig,
type RenovateOptions, type RenovateOptions,
type StatusCheckKey, type StatusCheckKey,
@ -32,7 +33,7 @@ import * as managerValidator from './validation-helpers/managers';
const options = getOptions(); const options = getOptions();
let optionTypes: Record<string, RenovateOptions['type']>; let optionTypes: Record<string, RenovateOptions['type']>;
let optionParents: Record<string, RenovateOptions['parent']>; let optionParents: Record<string, AllowedParents[]>;
let optionGlobals: Set<string>; let optionGlobals: Set<string>;
const managerList = getManagerList(); const managerList = getManagerList();
@ -117,8 +118,8 @@ export async function validateConfig(
if (!optionParents) { if (!optionParents) {
optionParents = {}; optionParents = {};
options.forEach((option) => { options.forEach((option) => {
if (option.parent) { if (option.parents) {
optionParents[option.name] = option.parent; optionParents[option.name] = option.parents;
} }
}); });
} }
@ -224,10 +225,12 @@ export async function validateConfig(
if ( if (
!isPreset && !isPreset &&
optionParents[key] && optionParents[key] &&
optionParents[key] !== parentName !optionParents[key].includes(parentName as AllowedParents)
) { ) {
// TODO: types (#22198) // TODO: types (#22198)
const message = `${key} should only be configured within a "${optionParents[key]}" object. Was found in ${parentName}`; const message = `${key} should only be configured within one of "${optionParents[
key
]?.join(' or ')}" objects. Was found in ${parentName}`;
warnings.push({ warnings.push({
topic: `${parentPath ? `${parentPath}.` : ''}${key}`, topic: `${parentPath ? `${parentPath}.` : ''}${key}`,
message, message,

View file

@ -31,7 +31,7 @@ describe('documentation', () => {
const expectedOptions = options const expectedOptions = options
.filter((option) => !option.globalOnly) .filter((option) => !option.globalOnly)
.filter((option) => !option.parent) .filter((option) => !option.parents)
.filter((option) => !option.autogenerated) .filter((option) => !option.autogenerated)
.map((option) => option.name) .map((option) => option.name)
.sort(); .sort();
@ -51,7 +51,7 @@ describe('documentation', () => {
const expectedSubOptions = options const expectedSubOptions = options
.filter((option) => option.stage !== 'global') .filter((option) => option.stage !== 'global')
.filter((option) => !option.globalOnly) .filter((option) => !option.globalOnly)
.filter((option) => option.parent) .filter((option) => option.parents)
.map((option) => option.name) .map((option) => option.name)
.sort(); .sort();
expectedSubOptions.sort(); expectedSubOptions.sort();

View file

@ -75,7 +75,7 @@ function createSingleConfig(option: RenovateOptions): Record<string, unknown> {
function createSchemaForParentConfigs(): void { function createSchemaForParentConfigs(): void {
for (const option of options) { for (const option of options) {
if (!option.parent) { if (!option.parents) {
properties[option.name] = createSingleConfig(option); properties[option.name] = createSingleConfig(option);
} }
} }
@ -83,30 +83,34 @@ function createSchemaForParentConfigs(): void {
function addChildrenArrayInParents(): void { function addChildrenArrayInParents(): void {
for (const option of options) { for (const option of options) {
if (option.parent) { if (option.parents) {
properties[option.parent].items = { for (const parent of option.parents) {
allOf: [ properties[parent].items = {
{ allOf: [
type: 'object', {
properties: { type: 'object',
description: { properties: {
type: 'string', description: {
description: type: 'string',
'A custom description for this configuration object', description:
'A custom description for this configuration object',
},
}, },
}, },
}, ],
], };
}; }
} }
} }
} }
function createSchemaForChildConfigs(): void { function createSchemaForChildConfigs(): void {
for (const option of options) { for (const option of options) {
if (option.parent) { if (option.parents) {
properties[option.parent].items.allOf[0].properties[option.name] = for (const parent of option.parents) {
createSingleConfig(option); properties[parent].items.allOf[0].properties[option.name] =
createSingleConfig(option);
}
} }
} }
} }