From 6fa37294cfb103f5b7a3c8e8b186303bfa4842ce Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 5 Feb 2021 22:21:24 +0100
Subject: [PATCH] refactor: dryRun admin config

---
 lib/config/admin.ts                           |  1 +
 lib/config/common.ts                          |  3 +--
 lib/workers/branch/automerge.spec.ts          |  4 +++-
 lib/workers/branch/automerge.ts               |  3 ++-
 lib/workers/branch/commit.spec.ts             |  4 +++-
 lib/workers/branch/commit.ts                  |  3 ++-
 lib/workers/branch/index.spec.ts              | 22 ++++++++++---------
 lib/workers/branch/index.ts                   | 10 ++++-----
 lib/workers/branch/reuse.ts                   |  3 ++-
 lib/workers/pr/index.ts                       | 17 +++++++-------
 .../repository/dependency-dashboard.spec.ts   |  6 ++++-
 .../repository/dependency-dashboard.ts        |  5 +++--
 lib/workers/repository/error-config.spec.ts   | 16 +++++++-------
 lib/workers/repository/error-config.ts        |  5 +++--
 lib/workers/repository/finalise/prune.spec.ts | 10 ++++++---
 lib/workers/repository/finalise/prune.ts      |  9 ++++----
 .../repository/onboarding/branch/create.ts    |  3 ++-
 .../repository/onboarding/branch/index.ts     |  3 ++-
 .../repository/onboarding/branch/rebase.ts    |  3 ++-
 .../repository/onboarding/pr/index.spec.ts    |  6 +++--
 lib/workers/repository/onboarding/pr/index.ts |  7 +++---
 lib/workers/repository/process/deprecated.ts  |  3 ++-
 22 files changed, 87 insertions(+), 59 deletions(-)

diff --git a/lib/config/admin.ts b/lib/config/admin.ts
index 3a112756b2..ed752a1fa0 100644
--- a/lib/config/admin.ts
+++ b/lib/config/admin.ts
@@ -8,6 +8,7 @@ export const repoAdminOptions = [
   'allowedPostUpgradeCommands',
   'dockerImagePrefix',
   'dockerUser',
+  'dryRun',
   'privateKey',
   'trustLevel',
 ];
diff --git a/lib/config/common.ts b/lib/config/common.ts
index f64f470de0..40a3730dae 100644
--- a/lib/config/common.ts
+++ b/lib/config/common.ts
@@ -86,6 +86,7 @@ export interface RepoAdminConfig {
   allowedPostUpgradeCommands?: string[];
   dockerImagePrefix?: string;
   dockerUser?: string;
+  dryRun?: boolean;
   privateKey?: string | Buffer;
   trustLevel?: 'low' | 'high';
 }
@@ -97,8 +98,6 @@ export interface RenovateAdminConfig {
 
   customEnvVariables?: Record<string, string>;
 
-  dryRun?: boolean;
-
   endpoint?: string;
 
   localDir?: string;
diff --git a/lib/workers/branch/automerge.spec.ts b/lib/workers/branch/automerge.spec.ts
index 7749de6854..4b8bce684d 100644
--- a/lib/workers/branch/automerge.spec.ts
+++ b/lib/workers/branch/automerge.spec.ts
@@ -1,5 +1,6 @@
 import { defaultConfig, git, platform } from '../../../test/util';
 import { RenovateConfig } from '../../config';
+import { setAdminConfig } from '../../config/admin';
 import { BranchStatus } from '../../types';
 import { tryBranchAutomerge } from './automerge';
 
@@ -12,6 +13,7 @@ describe('workers/branch/automerge', () => {
       config = {
         ...defaultConfig,
       };
+      setAdminConfig();
     });
     it('returns false if not configured for automerge', async () => {
       config.automerge = false;
@@ -61,7 +63,7 @@ describe('workers/branch/automerge', () => {
     it('returns true if automerge succeeds (dry-run)', async () => {
       config.automerge = true;
       config.automergeType = 'branch';
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       platform.getBranchStatus.mockResolvedValueOnce(BranchStatus.green);
       expect(await tryBranchAutomerge(config)).toBe('automerged');
     });
diff --git a/lib/workers/branch/automerge.ts b/lib/workers/branch/automerge.ts
index 34d310011b..707d4e8fa1 100644
--- a/lib/workers/branch/automerge.ts
+++ b/lib/workers/branch/automerge.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../config';
+import { getAdminConfig } from '../../config/admin';
 import { logger } from '../../logger';
 import { platform } from '../../platform';
 import { BranchStatus } from '../../types';
@@ -30,7 +31,7 @@ export async function tryBranchAutomerge(
   if (branchStatus === BranchStatus.green) {
     logger.debug(`Automerging branch`);
     try {
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info('DRY-RUN: Would automerge branch' + config.branchName);
       } else {
         await mergeBranch(config.branchName);
diff --git a/lib/workers/branch/commit.spec.ts b/lib/workers/branch/commit.spec.ts
index bd559cb48d..a22dbc05bf 100644
--- a/lib/workers/branch/commit.spec.ts
+++ b/lib/workers/branch/commit.spec.ts
@@ -1,4 +1,5 @@
 import { defaultConfig, git, partial } from '../../../test/util';
+import { setAdminConfig } from '../../config/admin';
 import { BranchConfig } from '../common';
 import { commitFilesToBranch } from './commit';
 
@@ -20,6 +21,7 @@ describe('workers/branch/automerge', () => {
       });
       jest.resetAllMocks();
       git.commitFiles.mockResolvedValueOnce('abc123');
+      setAdminConfig();
     });
     it('handles empty files', async () => {
       await commitFilesToBranch(config);
@@ -35,7 +37,7 @@ describe('workers/branch/automerge', () => {
       expect(git.commitFiles.mock.calls).toMatchSnapshot();
     });
     it('dry runs', async () => {
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       config.updatedPackageFiles.push({
         name: 'package.json',
         contents: 'some contents',
diff --git a/lib/workers/branch/commit.ts b/lib/workers/branch/commit.ts
index 4d57859b99..0ebcd5caa7 100644
--- a/lib/workers/branch/commit.ts
+++ b/lib/workers/branch/commit.ts
@@ -1,5 +1,6 @@
 import is from '@sindresorhus/is';
 import minimatch from 'minimatch';
+import { getAdminConfig } from '../../config/admin';
 import { CONFIG_SECRETS_EXPOSED } from '../../constants/error-messages';
 import { logger } from '../../logger';
 import { commitFiles } from '../../util/git';
@@ -31,7 +32,7 @@ export function commitFilesToBranch(
   const fileLength = [...new Set(updatedFiles.map((file) => file.name))].length;
   logger.debug(`${fileLength} file(s) to commit`);
   // istanbul ignore if
-  if (config.dryRun) {
+  if (getAdminConfig().dryRun) {
     logger.info('DRY-RUN: Would commit files to branch ' + config.branchName);
     return null;
   }
diff --git a/lib/workers/branch/index.spec.ts b/lib/workers/branch/index.spec.ts
index 3cf0eb1879..0c61dd50df 100644
--- a/lib/workers/branch/index.spec.ts
+++ b/lib/workers/branch/index.spec.ts
@@ -324,7 +324,8 @@ describe('workers/branch', () => {
       git.branchExists.mockReturnValueOnce(true);
       commit.commitFilesToBranch.mockResolvedValueOnce(null);
       automerge.tryBranchAutomerge.mockResolvedValueOnce('automerged');
-      await branchWorker.processBranch({ ...config, dryRun: true });
+      setAdminConfig({ dryRun: true });
+      await branchWorker.processBranch(config);
       expect(automerge.tryBranchAutomerge).toHaveBeenCalledTimes(1);
       expect(prWorker.ensurePr).toHaveBeenCalledTimes(0);
     });
@@ -553,9 +554,10 @@ describe('workers/branch', () => {
       checkExisting.prAlreadyExisted.mockResolvedValueOnce({
         state: PrState.Closed,
       } as never);
-      expect(
-        await branchWorker.processBranch({ ...config, dryRun: true })
-      ).toEqual(ProcessBranchResult.AlreadyExisted);
+      setAdminConfig({ dryRun: true });
+      expect(await branchWorker.processBranch(config)).toEqual(
+        ProcessBranchResult.AlreadyExisted
+      );
     });
 
     it('branch pr no rebase (dry run)', async () => {
@@ -564,9 +566,10 @@ describe('workers/branch', () => {
         state: PrState.Open,
       } as never);
       git.isBranchModified.mockResolvedValueOnce(true);
-      expect(
-        await branchWorker.processBranch({ ...config, dryRun: true })
-      ).toEqual(ProcessBranchResult.PrEdited);
+      setAdminConfig({ dryRun: true });
+      expect(await branchWorker.processBranch(config)).toEqual(
+        ProcessBranchResult.PrEdited
+      );
     });
 
     it('branch pr no schedule lockfile (dry run)', async () => {
@@ -587,11 +590,10 @@ describe('workers/branch', () => {
       git.isBranchModified.mockResolvedValueOnce(true);
       schedule.isScheduledNow.mockReturnValueOnce(false);
       commit.commitFilesToBranch.mockResolvedValueOnce(null);
-
+      setAdminConfig({ dryRun: true });
       expect(
         await branchWorker.processBranch({
           ...config,
-          dryRun: true,
           updateType: 'lockFileMaintenance',
           reuseExistingBranch: false,
           updatedArtifacts: [{ name: '|delete|', contents: 'dummy' }],
@@ -621,10 +623,10 @@ describe('workers/branch', () => {
         pr: {},
       } as never);
       commit.commitFilesToBranch.mockResolvedValueOnce(null);
+      setAdminConfig({ dryRun: true });
       expect(
         await branchWorker.processBranch({
           ...config,
-          dryRun: true,
           artifactErrors: [{}],
         })
       ).toEqual(ProcessBranchResult.Done);
diff --git a/lib/workers/branch/index.ts b/lib/workers/branch/index.ts
index 5271126c25..06e0cdbfa8 100644
--- a/lib/workers/branch/index.ts
+++ b/lib/workers/branch/index.ts
@@ -116,7 +116,7 @@ export async function processBranch(
         content +=
           '\n\nIf this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened.';
         if (!config.suppressNotifications.includes('prIgnoreNotification')) {
-          if (config.dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info(
               `DRY-RUN: Would ensure closed PR comment in PR #${existingPr.number}`
             );
@@ -129,7 +129,7 @@ export async function processBranch(
           }
         }
         if (branchExists) {
-          if (config.dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info('DRY-RUN: Would delete branch ' + config.branchName);
           } else {
             await deleteBranch(config.branchName);
@@ -644,7 +644,7 @@ export async function processBranch(
             config.suppressNotifications.includes('lockFileErrors')
           )
         ) {
-          if (config.dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info(
               `DRY-RUN: Would ensure lock file error comment in PR #${pr.number}`
             );
@@ -666,7 +666,7 @@ export async function processBranch(
         // Check if state needs setting
         if (existingState !== state) {
           logger.debug(`Updating status check state to failed`);
-          if (config.dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info(
               'DRY-RUN: Would set branch status in ' + config.branchName
             );
@@ -682,7 +682,7 @@ export async function processBranch(
       } else {
         if (config.updatedArtifacts?.length) {
           // istanbul ignore if
-          if (config.dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info(
               `DRY-RUN: Would ensure comment removal in PR #${pr.number}`
             );
diff --git a/lib/workers/branch/reuse.ts b/lib/workers/branch/reuse.ts
index ffcb27c440..37c268c716 100644
--- a/lib/workers/branch/reuse.ts
+++ b/lib/workers/branch/reuse.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../config';
+import { getAdminConfig } from '../../config/admin';
 import { logger } from '../../logger';
 import { platform } from '../../platform';
 import { branchExists, isBranchModified, isBranchStale } from '../../util/git';
@@ -34,7 +35,7 @@ export async function shouldReuseExistingBranch(
     if (pr.labels?.includes(config.rebaseLabel)) {
       logger.debug(`Manual rebase requested via PR labels for #${pr.number}`);
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info(
           `DRY-RUN: Would delete label ${config.rebaseLabel} from #${pr.number}`
         );
diff --git a/lib/workers/pr/index.ts b/lib/workers/pr/index.ts
index 5809e76340..4ab68cb8ec 100644
--- a/lib/workers/pr/index.ts
+++ b/lib/workers/pr/index.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../config';
+import { getAdminConfig } from '../../config/admin';
 import {
   PLATFORM_INTEGRATION_UNAUTHORIZED,
   PLATFORM_RATE_LIMIT_EXCEEDED,
@@ -52,7 +53,7 @@ export async function addAssigneesReviewers(
       }
       if (assignees.length > 0) {
         // istanbul ignore if
-        if (config.dryRun) {
+        if (getAdminConfig().dryRun) {
           logger.info(`DRY-RUN: Would add assignees to PR #${pr.number}`);
         } else {
           await platform.addAssignees(pr.number, assignees);
@@ -81,7 +82,7 @@ export async function addAssigneesReviewers(
       }
       if (reviewers.length > 0) {
         // istanbul ignore if
-        if (config.dryRun) {
+        if (getAdminConfig().dryRun) {
           logger.info(`DRY-RUN: Would add reviewers to PR #${pr.number}`);
         } else {
           await platform.addReviewers(pr.number, reviewers);
@@ -354,7 +355,7 @@ export async function ensurePr(
         );
       }
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info(`DRY-RUN: Would update PR #${existingPr.number}`);
       } else {
         await platform.updatePr({
@@ -375,7 +376,7 @@ export async function ensurePr(
     let pr: Pr;
     try {
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info('DRY-RUN: Would create PR: ' + prTitle);
         pr = { number: 0, displayNumber: 'Dry run PR' } as never;
       } else {
@@ -418,7 +419,7 @@ export async function ensurePr(
           { branch: branchName },
           'Deleting branch due to server error'
         );
-        if (config.dryRun) {
+        if (getAdminConfig().dryRun) {
           logger.info('DRY-RUN: Would delete branch: ' + config.branchName);
         } else {
           await deleteBranch(branchName);
@@ -439,7 +440,7 @@ export async function ensurePr(
       content = platform.getPrBody(content);
       logger.debug('Adding branch automerge failure message to PR');
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info(`DRY-RUN: Would add comment to PR #${pr.number}`);
       } else {
         await platform.ensureComment({
@@ -529,7 +530,7 @@ export async function checkAutoMerge(
     if (automergeType === 'pr-comment') {
       logger.debug(`Applying automerge comment: ${automergeComment}`);
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info(
           `DRY-RUN: Would add PR automerge comment to PR #${pr.number}`
         );
@@ -550,7 +551,7 @@ export async function checkAutoMerge(
     // Let's merge this
     logger.debug(`Automerging #${pr.number}`);
     // istanbul ignore if
-    if (config.dryRun) {
+    if (getAdminConfig().dryRun) {
       logger.info(`DRY-RUN: Would merge PR #${pr.number}`);
       return false;
     }
diff --git a/lib/workers/repository/dependency-dashboard.spec.ts b/lib/workers/repository/dependency-dashboard.spec.ts
index b71cd8922d..41b4990624 100644
--- a/lib/workers/repository/dependency-dashboard.spec.ts
+++ b/lib/workers/repository/dependency-dashboard.spec.ts
@@ -7,6 +7,7 @@ import {
   logger,
   platform,
 } from '../../../test/util';
+import { setAdminConfig } from '../../config/admin';
 import { PLATFORM_TYPE_GITHUB } from '../../constants/platforms';
 import { Platform, Pr } from '../../platform';
 import { PrState } from '../../types';
@@ -38,7 +39,7 @@ async function dryRun(
   findPrCalls = 0
 ) {
   jest.clearAllMocks();
-  config.dryRun = true;
+  setAdminConfig({ dryRun: true });
   await dependencyDashboard.ensureMasterIssue(config, branches);
   expect(platform.ensureIssueClosing).toHaveBeenCalledTimes(
     ensureIssueClosingCalls
@@ -50,6 +51,9 @@ async function dryRun(
 
 describe('workers/repository/master-issue', () => {
   describe('ensureMasterIssue()', () => {
+    beforeEach(() => {
+      setAdminConfig();
+    });
     it('do nothing if masterissue is disable', async () => {
       const branches: BranchConfig[] = [];
       await dependencyDashboard.ensureMasterIssue(config, branches);
diff --git a/lib/workers/repository/dependency-dashboard.ts b/lib/workers/repository/dependency-dashboard.ts
index 0e546c7c00..1ab14fc92e 100644
--- a/lib/workers/repository/dependency-dashboard.ts
+++ b/lib/workers/repository/dependency-dashboard.ts
@@ -1,6 +1,7 @@
 import is from '@sindresorhus/is';
 import { nameFromLevel } from 'bunyan';
 import { RenovateConfig } from '../../config';
+import { getAdminConfig } from '../../config/admin';
 import { getProblems, logger } from '../../logger';
 import { Pr, platform } from '../../platform';
 import { PrState } from '../../types';
@@ -76,7 +77,7 @@ export async function ensureMasterIssue(
     is.nonEmptyArray(branches) &&
     branches.some((branch) => branch.res !== ProcessBranchResult.Automerged);
   if (config.dependencyDashboardAutoclose && !hasBranches) {
-    if (config.dryRun) {
+    if (getAdminConfig().dryRun) {
       logger.info(
         'DRY-RUN: Would close Dependency Dashboard ' +
           config.dependencyDashboardTitle
@@ -239,7 +240,7 @@ export async function ensureMasterIssue(
     issueBody += `---\n${config.dependencyDashboardFooter}\n`;
   }
 
-  if (config.dryRun) {
+  if (getAdminConfig().dryRun) {
     logger.info(
       'DRY-RUN: Would ensure Dependency Dashboard ' +
         config.dependencyDashboardTitle
diff --git a/lib/workers/repository/error-config.spec.ts b/lib/workers/repository/error-config.spec.ts
index d6cf860ba4..dd5cc24c0a 100644
--- a/lib/workers/repository/error-config.spec.ts
+++ b/lib/workers/repository/error-config.spec.ts
@@ -1,5 +1,6 @@
 import { mock } from 'jest-mock-extended';
 import { RenovateConfig, getConfig, platform } from '../../../test/util';
+import { setAdminConfig } from '../../config/admin';
 import { CONFIG_VALIDATION } from '../../constants/error-messages';
 import { Pr } from '../../platform';
 import { PrState } from '../../types';
@@ -15,6 +16,9 @@ beforeEach(() => {
 
 describe('workers/repository/error-config', () => {
   describe('raiseConfigWarningIssue()', () => {
+    beforeEach(() => {
+      setAdminConfig();
+    });
     it('creates issues', async () => {
       const error = new Error(CONFIG_VALIDATION);
       error.configFile = 'package.json';
@@ -28,10 +32,8 @@ describe('workers/repository/error-config', () => {
       error.configFile = 'package.json';
       error.validationMessage = 'some-message';
       platform.ensureIssue.mockResolvedValueOnce('created');
-      const res = await raiseConfigWarningIssue(
-        { ...config, dryRun: true },
-        error
-      );
+      setAdminConfig({ dryRun: true });
+      const res = await raiseConfigWarningIssue(config, error);
       expect(res).toBeUndefined();
     });
     it('handles onboarding', async () => {
@@ -55,10 +57,8 @@ describe('workers/repository/error-config', () => {
         number: 1,
         state: PrState.Open,
       });
-      const res = await raiseConfigWarningIssue(
-        { ...config, dryRun: true },
-        error
-      );
+      setAdminConfig({ dryRun: true });
+      const res = await raiseConfigWarningIssue(config, error);
       expect(res).toBeUndefined();
     });
   });
diff --git a/lib/workers/repository/error-config.ts b/lib/workers/repository/error-config.ts
index 3359f9224c..c3067ff5cd 100644
--- a/lib/workers/repository/error-config.ts
+++ b/lib/workers/repository/error-config.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../config';
+import { getAdminConfig } from '../../config/admin';
 import { logger } from '../../logger';
 import { platform } from '../../platform';
 import { PrState } from '../../types';
@@ -21,7 +22,7 @@ export async function raiseConfigWarningIssue(
     logger.debug('Updating onboarding PR with config error notice');
     body = `## Action Required: Fix Renovate Configuration\n\n${body}`;
     body += `\n\nOnce you have resolved this problem (in this onboarding branch), Renovate will return to providing you with a preview of your repository's configuration.`;
-    if (config.dryRun) {
+    if (getAdminConfig().dryRun) {
       logger.info(`DRY-RUN: Would update PR #${pr.number}`);
     } else {
       await platform.updatePr({
@@ -30,7 +31,7 @@ export async function raiseConfigWarningIssue(
         prBody: body,
       });
     }
-  } else if (config.dryRun) {
+  } else if (getAdminConfig().dryRun) {
     logger.info('DRY-RUN: Would ensure config error issue');
   } else {
     const once = false;
diff --git a/lib/workers/repository/finalise/prune.spec.ts b/lib/workers/repository/finalise/prune.spec.ts
index 2d475b99b0..f4e78e436f 100644
--- a/lib/workers/repository/finalise/prune.spec.ts
+++ b/lib/workers/repository/finalise/prune.spec.ts
@@ -4,6 +4,7 @@ import {
   git,
   platform,
 } from '../../../../test/util';
+import { setAdminConfig } from '../../../config/admin';
 import { PLATFORM_TYPE_GITHUB } from '../../../constants/platforms';
 import * as cleanup from './prune';
 
@@ -20,6 +21,9 @@ beforeEach(() => {
 
 describe('workers/repository/finalise/prune', () => {
   describe('pruneStaleBranches()', () => {
+    beforeEach(() => {
+      setAdminConfig();
+    });
     it('returns if no branchList', async () => {
       delete config.branchList;
       await cleanup.pruneStaleBranches(config, config.branchList);
@@ -65,7 +69,7 @@ describe('workers/repository/finalise/prune', () => {
     });
     it('does nothing on dryRun', async () => {
       config.branchList = ['renovate/a', 'renovate/b'];
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
@@ -105,7 +109,7 @@ describe('workers/repository/finalise/prune', () => {
     });
     it('skips comment if dry run', async () => {
       config.branchList = ['renovate/a', 'renovate/b'];
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
@@ -120,7 +124,7 @@ describe('workers/repository/finalise/prune', () => {
     });
     it('dry run delete branch no PR', async () => {
       config.branchList = ['renovate/a', 'renovate/b'];
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       git.getBranchList.mockReturnValueOnce(
         config.branchList.concat(['renovate/c'])
       );
diff --git a/lib/workers/repository/finalise/prune.ts b/lib/workers/repository/finalise/prune.ts
index 8c89298115..a2a621f144 100644
--- a/lib/workers/repository/finalise/prune.ts
+++ b/lib/workers/repository/finalise/prune.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../config';
+import { getAdminConfig } from '../../../config/admin';
 import { REPOSITORY_CHANGED } from '../../../constants/error-messages';
 import { logger } from '../../../logger';
 import { platform } from '../../../platform';
@@ -10,7 +11,7 @@ import {
 } from '../../../util/git';
 
 async function cleanUpBranches(
-  { dryRun, pruneStaleBranches: enabled }: RenovateConfig,
+  { pruneStaleBranches: enabled }: RenovateConfig,
   remainingBranches: string[]
 ): Promise<void> {
   if (enabled === false) {
@@ -30,7 +31,7 @@ async function cleanUpBranches(
             { prNo: pr.number, prTitle: pr.title },
             'Branch is modified - skipping PR autoclosing'
           );
-          if (dryRun) {
+          if (getAdminConfig().dryRun) {
             logger.info(`DRY-RUN: Would add Autoclosing Skipped comment to PR`);
           } else {
             await platform.ensureComment({
@@ -40,7 +41,7 @@ async function cleanUpBranches(
                 'This PR has been flagged for autoclosing, however it is being skipped due to the branch being already modified. Please close/delete it manually or report a bug if you think this is in error.',
             });
           }
-        } else if (dryRun) {
+        } else if (getAdminConfig().dryRun) {
           logger.info(
             { prNo: pr.number, prTitle: pr.title },
             `DRY-RUN: Would autoclose PR`
@@ -61,7 +62,7 @@ async function cleanUpBranches(
           });
           await deleteBranch(branchName);
         }
-      } else if (dryRun) {
+      } else if (getAdminConfig().dryRun) {
         logger.info(`DRY-RUN: Would delete orphan branch ${branchName}`);
       } else {
         logger.info({ branch: branchName }, `Deleting orphan branch`);
diff --git a/lib/workers/repository/onboarding/branch/create.ts b/lib/workers/repository/onboarding/branch/create.ts
index 8fa32831b3..0bd094d7d9 100644
--- a/lib/workers/repository/onboarding/branch/create.ts
+++ b/lib/workers/repository/onboarding/branch/create.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../../config';
+import { getAdminConfig } from '../../../../config/admin';
 import { configFileNames } from '../../../../config/app-strings';
 import { logger } from '../../../../logger';
 import { commitFiles } from '../../../../util/git';
@@ -43,7 +44,7 @@ export async function createOnboardingBranch(
   const commitMessage = `${commitMessagePrefix} ${onboardingCommitMessage}`.trim();
 
   // istanbul ignore if
-  if (config.dryRun) {
+  if (getAdminConfig().dryRun) {
     logger.info('DRY-RUN: Would commit files to onboarding branch');
     return null;
   }
diff --git a/lib/workers/repository/onboarding/branch/index.ts b/lib/workers/repository/onboarding/branch/index.ts
index 2da046e8d9..abfe3bd0c2 100644
--- a/lib/workers/repository/onboarding/branch/index.ts
+++ b/lib/workers/repository/onboarding/branch/index.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../../config';
+import { getAdminConfig } from '../../../../config/admin';
 import {
   MANAGER_NO_PACKAGE_FILES,
   REPOSITORY_FORKED,
@@ -54,7 +55,7 @@ export async function checkOnboardingBranch(
       );
     }
   }
-  if (!config.dryRun) {
+  if (!getAdminConfig().dryRun) {
     await checkoutBranch(config.onboardingBranch);
   }
   const branchList = [config.onboardingBranch];
diff --git a/lib/workers/repository/onboarding/branch/rebase.ts b/lib/workers/repository/onboarding/branch/rebase.ts
index b2ca91a56d..aa4557e436 100644
--- a/lib/workers/repository/onboarding/branch/rebase.ts
+++ b/lib/workers/repository/onboarding/branch/rebase.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../../config';
+import { getAdminConfig } from '../../../../config/admin';
 import { configFileNames } from '../../../../config/app-strings';
 import { logger } from '../../../../logger';
 import {
@@ -54,7 +55,7 @@ export async function rebaseOnboardingBranch(
   const commitMessage = getCommitMessage(config);
 
   // istanbul ignore if
-  if (config.dryRun) {
+  if (getAdminConfig().dryRun) {
     logger.info('DRY-RUN: Would rebase files in onboarding branch');
     return null;
   }
diff --git a/lib/workers/repository/onboarding/pr/index.spec.ts b/lib/workers/repository/onboarding/pr/index.spec.ts
index d1b9ebcfd9..6b9e02b4a2 100644
--- a/lib/workers/repository/onboarding/pr/index.spec.ts
+++ b/lib/workers/repository/onboarding/pr/index.spec.ts
@@ -5,6 +5,7 @@ import {
   partial,
   platform,
 } from '../../../../../test/util';
+import { setAdminConfig } from '../../../../config/admin';
 import { logger } from '../../../../logger';
 import { PackageFile } from '../../../../manager/common';
 import { Pr } from '../../../../platform';
@@ -30,6 +31,7 @@ describe('workers/repository/onboarding/pr', () => {
       branches = [];
       platform.getPrBody = jest.fn((input) => input);
       platform.createPr.mockResolvedValueOnce(partial<Pr>({}));
+      setAdminConfig();
     });
     let createPrBody: string;
     it('returns if onboarded', async () => {
@@ -87,7 +89,7 @@ describe('workers/repository/onboarding/pr', () => {
       expect(platform.createPr).toHaveBeenCalledTimes(1);
     });
     it('dryrun of updates PR when modified', async () => {
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       config.baseBranch = 'some-branch';
       platform.getBranchPr.mockResolvedValueOnce(
         partial<Pr>({
@@ -106,7 +108,7 @@ describe('workers/repository/onboarding/pr', () => {
       );
     });
     it('dryrun of creates PR', async () => {
-      config.dryRun = true;
+      setAdminConfig({ dryRun: true });
       await ensureOnboardingPr(config, packageFiles, branches);
       expect(logger.info).toHaveBeenCalledWith(
         'DRY-RUN: Would check branch renovate/configure'
diff --git a/lib/workers/repository/onboarding/pr/index.ts b/lib/workers/repository/onboarding/pr/index.ts
index 09359071d0..d688979211 100644
--- a/lib/workers/repository/onboarding/pr/index.ts
+++ b/lib/workers/repository/onboarding/pr/index.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../../config';
+import { getAdminConfig } from '../../../../config/admin';
 import { logger } from '../../../../logger';
 import { PackageFile } from '../../../../manager/common';
 import { platform } from '../../../../platform';
@@ -65,7 +66,7 @@ If you need any further assistance then you can also [request help here](${confi
     prBody = prBody.replace('{{PACKAGE FILES}}\n', '');
   }
   let configDesc = '';
-  if (config.dryRun) {
+  if (getAdminConfig().dryRun) {
     logger.info(`DRY-RUN: Would check branch ${config.onboardingBranch}`);
   } else if (await isBranchModified(config.onboardingBranch)) {
     configDesc = emojify(
@@ -113,7 +114,7 @@ If you need any further assistance then you can also [request help here](${confi
       return;
     }
     // PR must need updating
-    if (config.dryRun) {
+    if (getAdminConfig().dryRun) {
       logger.info('DRY-RUN: Would update onboarding PR');
     } else {
       await platform.updatePr({
@@ -128,7 +129,7 @@ If you need any further assistance then you can also [request help here](${confi
   logger.debug('Creating onboarding PR');
   const labels: string[] = [];
   try {
-    if (config.dryRun) {
+    if (getAdminConfig().dryRun) {
       logger.info('DRY-RUN: Would create onboarding PR');
     } else {
       const pr = await platform.createPr({
diff --git a/lib/workers/repository/process/deprecated.ts b/lib/workers/repository/process/deprecated.ts
index 53e3a9d6f8..639fd7a0d5 100644
--- a/lib/workers/repository/process/deprecated.ts
+++ b/lib/workers/repository/process/deprecated.ts
@@ -1,4 +1,5 @@
 import { RenovateConfig } from '../../../config';
+import { getAdminConfig } from '../../../config/admin';
 import { logger } from '../../../logger';
 import { PackageFile } from '../../../manager/common';
 import { platform } from '../../../platform';
@@ -54,7 +55,7 @@ export async function raiseDeprecationWarnings(
         .join(', ')}`;
       issueBody += `\n\nIf you don't care about this, you can close this issue and not be warned about \`${depName}\`'s deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:\n\n\`\`\`\n"suppressNotifications": ["deprecationWarningIssues"]\n\`\`\`\n\n`;
       // istanbul ignore if
-      if (config.dryRun) {
+      if (getAdminConfig().dryRun) {
         logger.info('DRY-RUN: Ensure deprecation warning issue for ' + depName);
       } else {
         const ensureOnce = true;
-- 
GitLab