From 88e5e97e6a007b6202737bb7fa0574916574dc9c Mon Sep 17 00:00:00 2001 From: Rhys Arkins Date: Wed, 27 Mar 2024 04:08:25 +0100 Subject: [PATCH] fix(config)!: globalExtends merge order (#28145) Previously, config from globalExtends was incorrectly merged _after_ other global config. This meant for example that packageRules in a config.js could not override packageRules from within globalExtends, because they were applied after. Now, globalExtends content will be merged first, and remaining global config merged second. Fixes #28131 BREAKING CHANGE: order of globalExtends resolution is changed so that it is applied first and remaining global config takes precedence. --- docs/usage/self-hosted-experimental.md | 4 ---- lib/workers/global/index.spec.ts | 16 ---------------- lib/workers/global/index.ts | 15 ++++----------- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/docs/usage/self-hosted-experimental.md b/docs/usage/self-hosted-experimental.md index f6118f1f15659e..c56d33c4e17f29 100644 --- a/docs/usage/self-hosted-experimental.md +++ b/docs/usage/self-hosted-experimental.md @@ -48,10 +48,6 @@ If set to any value, Renovate will use the Docker Hub API (`https://hub.docker.c If set to an integer, Renovate will use this as max page number for docker tags lookup on docker registries, instead of the default 20 pages. This is useful for registries which ignores the `n` parameter in the query string and only return 50 tags per page. -## `RENOVATE_X_EAGER_GLOBAL_EXTENDS` - -Resolve and merge `globalExtends` presets before other global config, instead of after. - ## `RENOVATE_X_EXEC_GPID_HANDLE` If set, Renovate will terminate the whole process group of a terminated child process spawned by Renovate. diff --git a/lib/workers/global/index.spec.ts b/lib/workers/global/index.spec.ts index a75815c0252165..6ee3c4a84e1859 100644 --- a/lib/workers/global/index.spec.ts +++ b/lib/workers/global/index.spec.ts @@ -45,7 +45,6 @@ describe('workers/global/index', () => { initPlatform.mockImplementation((input) => Promise.resolve(input)); delete process.env.AWS_SECRET_ACCESS_KEY; delete process.env.AWS_SESSION_TOKEN; - delete process.env.RENOVATE_X_EAGER_GLOBAL_EXTENDS; }); describe('getRepositoryConfig', () => { @@ -88,21 +87,6 @@ describe('workers/global/index', () => { expect(addSecretForSanitizing).toHaveBeenCalledTimes(2); }); - it('resolves global presets first', async () => { - process.env.RENOVATE_X_EAGER_GLOBAL_EXTENDS = 'true'; - parseConfigs.mockResolvedValueOnce({ - repositories: [], - globalExtends: [':pinVersions'], - hostRules: [{ matchHost: 'github.com', token: 'abc123' }], - }); - presets.resolveConfigPresets.mockResolvedValueOnce({}); - await expect(globalWorker.start()).resolves.toBe(0); - expect(presets.resolveConfigPresets).toHaveBeenCalledWith({ - extends: [':pinVersions'], - }); - expect(parseConfigs).toHaveBeenCalledTimes(1); - }); - it('resolves global presets immediately', async () => { parseConfigs.mockResolvedValueOnce({ repositories: [], diff --git a/lib/workers/global/index.ts b/lib/workers/global/index.ts index 9a53fdce8a31d3..5ec413d1daeee2 100644 --- a/lib/workers/global/index.ts +++ b/lib/workers/global/index.ts @@ -144,17 +144,10 @@ export async function start(): Promise { config = await getGlobalConfig(); if (config?.globalExtends) { // resolve global presets immediately - if (process.env.RENOVATE_X_EAGER_GLOBAL_EXTENDS) { - config = mergeChildConfig( - await resolveGlobalExtends(config.globalExtends), - config, - ); - } else { - config = mergeChildConfig( - config, - await resolveGlobalExtends(config.globalExtends), - ); - } + config = mergeChildConfig( + await resolveGlobalExtends(config.globalExtends), + config, + ); } // Set allowedHeaders in case hostRules headers are configured in file config