Skip to content

Commit

Permalink
refactor: move customEnvVariables to admin config
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 7, 2021
1 parent 3ebfb5f commit 80fd1fe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions lib/config/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let adminConfig: RepoAdminConfig = {};
export const repoAdminOptions = [
'allowPostUpgradeCommandTemplating',
'allowedPostUpgradeCommands',
'customEnvVariables',
'dockerImagePrefix',
'dockerUser',
'dryRun',
Expand Down
3 changes: 1 addition & 2 deletions lib/config/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface GlobalAdminConfig {
export interface RepoAdminConfig {
allowPostUpgradeCommandTemplating?: boolean;
allowedPostUpgradeCommands?: string[];
customEnvVariables?: Record<string, string>;
dockerImagePrefix?: string;
dockerUser?: string;
dryRun?: boolean;
Expand All @@ -95,8 +96,6 @@ export interface RepoAdminConfig {
export interface RenovateAdminConfig {
cacheDir?: string;

customEnvVariables?: Record<string, string>;

endpoint?: string;

localDir?: string;
Expand Down
1 change: 0 additions & 1 deletion lib/util/exec/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export enum BinarySource {

export interface ExecConfig {
binarySource: Opt<BinarySource>;
customEnvVariables: Opt<Record<string, string>>;
localDir: Opt<string>;
cacheDir: Opt<string>;
}
Expand Down
32 changes: 20 additions & 12 deletions lib/util/exec/exec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,6 @@ describe(`Child process execution wrapper`, () => {
{
execConfig: {
...execConfig,
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_VALUE',
},
},
processEnv: envMock.basic,
inCmd,
Expand All @@ -559,6 +556,11 @@ describe(`Child process execution wrapper`, () => {
maxBuffer: 10485760,
},
],
adminConfig: {
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_VALUE',
},
},
},
],

Expand All @@ -567,9 +569,6 @@ describe(`Child process execution wrapper`, () => {
{
execConfig: {
...execConfig,
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_OVERRIDEN_VALUE',
},
},
processEnv: { ...envMock.basic, CUSTOM_KEY: 'CUSTOM_VALUE' },
inCmd,
Expand All @@ -584,6 +583,11 @@ describe(`Child process execution wrapper`, () => {
maxBuffer: 10485760,
},
],
adminConfig: {
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_OVERRIDEN_VALUE',
},
},
},
],

Expand All @@ -593,9 +597,6 @@ describe(`Child process execution wrapper`, () => {
execConfig: {
...execConfig,
binarySource: BinarySource.Docker,
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_VALUE',
},
},
processEnv,
inCmd,
Expand All @@ -616,6 +617,11 @@ describe(`Child process execution wrapper`, () => {
maxBuffer: 10485760,
},
],
adminConfig: {
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_VALUE',
},
},
},
],

Expand All @@ -625,9 +631,6 @@ describe(`Child process execution wrapper`, () => {
execConfig: {
...execConfig,
binarySource: BinarySource.Docker,
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_OVERRIDEN_VALUE',
},
},
processEnv: { ...envMock.basic, CUSTOM_KEY: 'CUSTOM_VALUE' },
inCmd,
Expand All @@ -648,6 +651,11 @@ describe(`Child process execution wrapper`, () => {
maxBuffer: 10485760,
},
],
adminConfig: {
customEnvVariables: {
CUSTOM_KEY: 'CUSTOM_OVERRIDEN_VALUE',
},
},
},
],
];
Expand Down
4 changes: 2 additions & 2 deletions lib/util/exec/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ExecOptions as ChildProcessExecOptions } from 'child_process';
import { dirname, join } from 'upath';
import { getAdminConfig } from '../../config/admin';
import { RenovateConfig } from '../../config/common';
import { logger } from '../../logger';
import {
Expand All @@ -20,7 +21,6 @@ import { getChildProcessEnv } from './env';

const execConfig: ExecConfig = {
binarySource: null,
customEnvVariables: null,
localDir: null,
cacheDir: null,
};
Expand Down Expand Up @@ -94,7 +94,7 @@ export async function exec(
opts: ExecOptions = {}
): Promise<ExecResult> {
const { env, docker, cwdFile } = opts;
const extraEnv = { ...opts.extraEnv, ...execConfig.customEnvVariables };
const extraEnv = { ...opts.extraEnv, ...getAdminConfig().customEnvVariables };
let cwd;
// istanbul ignore if
if (cwdFile) {
Expand Down

0 comments on commit 80fd1fe

Please sign in to comment.