From f0795fcae196bb62c80abd15351f3b228c472900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6ran=20Sander?= Date: Wed, 24 Apr 2024 19:26:51 +0000 Subject: [PATCH] feat(config): Add cmd line option "--skip-config-verification" Implements #1114 --- src/butler.js | 44 +++++++++++++++++++++++--------------------- src/globals.js | 4 +++- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/butler.js b/src/butler.js index fd1fa7f8..7cc44336 100644 --- a/src/butler.js +++ b/src/butler.js @@ -51,32 +51,34 @@ const start = async () => { } // Verify correct structure of config file - resAssert = await configFileStructureAssert(globals.config, globals.logger); - if (resAssert === false) { - globals.logger.error('MAIN: Config file structure is incorrect. Exiting.'); - process.exit(1); - } else { - globals.logger.info('MAIN: Config file structure is correct - all good.'); - } - - // Verify select parts/values in config file - if (globals.options.qsConnection) { - // Verify that the config file contains the required data related to New Relic - resAssert = await configFileNewRelicAssert(globals.config, globals.configQRS, globals.logger); + if (!settingsObj.options.skipConfigVerification) { + resAssert = await configFileStructureAssert(globals.config, globals.logger); if (resAssert === false) { - globals.logger.error('MAIN: Config file does not contain required New Relic data. Exiting.'); + globals.logger.error('MAIN: Config file structure is incorrect. Exiting.'); process.exit(1); } else { - globals.logger.info('MAIN: Config file contains required New Relic data - all good.'); + globals.logger.info('MAIN: Config file structure is correct - all good.'); } - // Verify that the config file contains the required data related to InfluxDb - resAssert = await configFileInfluxDbAssert(globals.config, globals.configQRS, globals.logger); - if (resAssert === false) { - globals.logger.error('MAIN: Config file does not contain required InfluxDb data. Exiting.'); - process.exit(1); - } else { - globals.logger.info('MAIN: Config file contains required InfluxDb data - all good.'); + // Verify select parts/values in config file + if (globals.options.qsConnection) { + // Verify that the config file contains the required data related to New Relic + resAssert = await configFileNewRelicAssert(globals.config, globals.configQRS, globals.logger); + if (resAssert === false) { + globals.logger.error('MAIN: Config file does not contain required New Relic data. Exiting.'); + process.exit(1); + } else { + globals.logger.info('MAIN: Config file contains required New Relic data - all good.'); + } + + // Verify that the config file contains the required data related to InfluxDb + resAssert = await configFileInfluxDbAssert(globals.config, globals.configQRS, globals.logger); + if (resAssert === false) { + globals.logger.error('MAIN: Config file does not contain required InfluxDb data. Exiting.'); + process.exit(1); + } else { + globals.logger.info('MAIN: Config file contains required InfluxDb data - all good.'); + } } } diff --git a/src/globals.js b/src/globals.js index 7a927142..bcfee8da 100644 --- a/src/globals.js +++ b/src/globals.js @@ -82,7 +82,9 @@ class Settings { '--api-rate-limit', 'set the API rate limit, per minute. Default is 100 calls/minute. Set to 0 to disable rate limiting.', 100 - ); + ) + + .option('--skip-config-verification', 'Disable config file verification', false); // Parse command line params program.parse(process.argv);