Skip to content

Commit

Permalink
feat(config): Add cmd line option "--skip-config-verification"
Browse files Browse the repository at this point in the history
Implements #1114
  • Loading branch information
Göran Sander committed Apr 24, 2024
1 parent ced7aa9 commit f0795fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
44 changes: 23 additions & 21 deletions src/butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f0795fc

Please sign in to comment.