From 31785b874233d73f3061f0022dde0d29e3f86e4a Mon Sep 17 00:00:00 2001 From: Sergei Zharinov <zharinov@users.noreply.github.com> Date: Fri, 23 Jul 2021 14:09:30 +0400 Subject: [PATCH] fix(config): Replace '__' to '_' globally when decoding hostRules from env (#10939) --- lib/workers/global/config/parse/env.spec.ts | 15 +++++++++++++++ lib/workers/global/config/parse/env.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/workers/global/config/parse/env.spec.ts b/lib/workers/global/config/parse/env.spec.ts index 4aa0158a87..3b8398455b 100644 --- a/lib/workers/global/config/parse/env.spec.ts +++ b/lib/workers/global/config/parse/env.spec.ts @@ -114,6 +114,21 @@ describe(getName(), () => { expect(res).toMatchSnapshot(); expect(res.hostRules).toHaveLength(2); }); + it('regression test for #10937', () => { + const envParam: NodeJS.ProcessEnv = { + GIT__TAGS_GITLAB_EXAMPLE__DOMAIN_NET_USERNAME: 'some-user', + GIT__TAGS_GITLAB_EXAMPLE__DOMAIN_NET_PASSWORD: 'some-password', + }; + const res = env.getConfig(envParam); + expect(res.hostRules).toMatchObject([ + { + hostType: 'git-tags', + matchHost: 'gitlab.example-domain.net', + password: 'some-password', + username: 'some-user', + }, + ]); + }); it('supports datasource env token', () => { const envParam: NodeJS.ProcessEnv = { PYPI_TOKEN: 'some-token', diff --git a/lib/workers/global/config/parse/env.ts b/lib/workers/global/config/parse/env.ts index 3fa43334fb..646f5f6b5a 100644 --- a/lib/workers/global/config/parse/env.ts +++ b/lib/workers/global/config/parse/env.ts @@ -100,7 +100,7 @@ export function getConfig(env: NodeJS.ProcessEnv): AllConfig { continue; // eslint-disable-line no-continue } // Double underscore __ is used in place of hyphen - - const splitEnv = envName.toLowerCase().replace('__', '-').split('_'); + const splitEnv = envName.toLowerCase().replace(/__/g, '-').split('_'); const hostType = splitEnv.shift(); if (datasources.has(hostType)) { const suffix = splitEnv.pop(); -- GitLab