Skip to content

Commit

Permalink
feat: Verify structure of config file on Butler startup
Browse files Browse the repository at this point in the history
Implements #675
  • Loading branch information
Göran Sander committed May 29, 2023
1 parent f7811f4 commit 69e35ff
Show file tree
Hide file tree
Showing 2 changed files with 1,801 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const winston = require('winston');

// Add dependencies
const { Command, Option } = require('commander');
const { configFileNewRelicAssert } = require('./lib/assert/assert_config_file');
const { configFileNewRelicAssert, configFileStructureAssert, configFileYamlAssert } = require('./lib/assert/assert_config_file');

require('winston-daily-rotate-file');

Expand Down Expand Up @@ -96,6 +96,9 @@ if (options.configfile && options.configfile.length > 0) {
configFileExpanded = upath.resolve(__dirname, `./config/${env}.yaml`);
}

// Verify that config file is valid YAML
configFileYamlAssert(configFileExpanded);

// Are we running as standalone app or not?
const isPkg = typeof process.pkg !== 'undefined';
if (isPkg && configFileOption === undefined) {
Expand Down Expand Up @@ -182,6 +185,9 @@ const getLoggingLevel = () => logTransports.find((transport) => transport.name =
// Are we running as standalone app or not?
logger.verbose(`Running as standalone app: ${isPkg}`);

// Verify correct structure of config file
configFileStructureAssert(config, logger);

// Helper function to read the contents of the certificate files:
const readCert = (filename) => fs.readFileSync(filename);

Expand Down
Loading

0 comments on commit 69e35ff

Please sign in to comment.