From 0cb45ddbf3b782ddff61b18b18cde04d8fd2914c Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 5 Apr 2021 11:19:08 +0200 Subject: [PATCH] feat: ENV_PREFIX (#9397) --- docs/usage/self-hosting.md | 2 ++ lib/config/env.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/usage/self-hosting.md b/docs/usage/self-hosting.md index 6ee632fef2..d17d179c95 100644 --- a/docs/usage/self-hosting.md +++ b/docs/usage/self-hosting.md @@ -208,6 +208,8 @@ If you are configuring using environment variables, there are two possibilities: If you combine both of the above then any single config option in the environment variable will override what's in `RENOVATE_CONFIG`. +Note: it's also possible to change the default prefix from `RENOVATE_` using `ENV_PREFIX`. e.g. `ENV_PREFIX=RNV_ RNV_TOKEN=abc123 renovate`. + ## Authentication Regardless of platform, you need to select a user account for `renovate` to assume the identity of, and generate a Personal Access Token. diff --git a/lib/config/env.ts b/lib/config/env.ts index cb7dcf10a4..c27e092eea 100644 --- a/lib/config/env.ts +++ b/lib/config/env.ts @@ -6,6 +6,15 @@ import { logger } from '../logger'; import { getOptions } from './definitions'; import type { GlobalConfig, RenovateOptions } from './types'; +// istanbul ignore if +if (process.env.ENV_PREFIX) { + for (const [key, val] of Object.entries(process.env)) { + if (key.startsWith(process.env.ENV_PREFIX)) { + process.env[key.replace(process.env.ENV_PREFIX, 'RENOVATE_')] = val; + } + } +} + export function getEnvName(option: Partial<RenovateOptions>): string { if (option.env === false) { return ''; -- GitLab