Skip to content

Commit

Permalink
refactor(config): Better verification of config file during startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Göran Sander committed Sep 27, 2024
1 parent 1d4a62d commit d1ebfaa
Show file tree
Hide file tree
Showing 7 changed files with 8,832 additions and 5,356 deletions.
663 changes: 290 additions & 373 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@
"@fastify/swagger-ui": "^4.1.0",
"@keyvhq/core": "^2.1.1",
"@xstate/fsm": "^2.0.1",
"ajv": "^8.17.1",
"ajv-keywords": "^5.1.0",
"any-base": "^1.1.0",
"axios": "^1.7.5",
"axios": "^1.7.7",
"commander": "^12.1.0",
"config": "^3.3.12",
"cron-job-manager": "^2.3.1",
"email-validator": "^2.0.4",
"enigma.js": "^2.14.0",
"esbuild": "^0.23.1",
"express-handlebars": "^7.1.3",
"fastify": "^4.28.1",
"fastify-healthcheck": "^4.4.0",
Expand All @@ -79,15 +80,14 @@
"is-unc-path": "^1.0.0",
"jjsontree.js": "^2.9.0",
"js-yaml": "^4.1.0",
"jshint": "^2.13.6",
"lodash": "^4.17.21",
"luxon": "^3.5.0",
"mkdirp": "^3.0.1",
"moment": "^2.30.1",
"moment-precise-range-plugin": "^1.3.0",
"mqtt": "^5.10.0",
"mqtt": "^5.10.1",
"ms-teams-wrapper": "^1.0.2",
"nodemailer": "^6.9.14",
"nodemailer": "^6.9.15",
"nodemailer-express-handlebars": "^6.1.2",
"os": "^0.1.2",
"posthog-node": "^4.2.0",
Expand All @@ -101,17 +101,18 @@
"winston": "^3.14.2",
"winston-daily-rotate-file": "^5.0.0",
"ws": "^8.18.0",
"xstate": "^5.17.4"
"xstate": "^5.18.2"
},
"devDependencies": {
"@babel/eslint-parser": "^7.25.1",
"@babel/plugin-syntax-import-assertions": "^7.24.7",
"@eslint/js": "^9.9.0",
"@babel/plugin-syntax-import-assertions": "^7.25.6",
"@eslint/js": "^9.11.1",
"esbuild": "^0.24.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"snyk": "^1.1292.4"
"snyk": "^1.1293.1"
},
"pkg": {
"assets": [
Expand Down
13 changes: 3 additions & 10 deletions src/butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,15 @@ const start = async () => {
const udpInitTaskErrorServer = (await import('./udp/udp_handlers.js')).default;
const mqttInitHandlers = (await import('./lib/mqtt_handlers.js')).default;

const { configFileStructureAssert, configFileYamlAssert, configFileNewRelicAssert, configFileInfluxDbAssert } = await import(
const { configFileStructureAssert, configFileNewRelicAssert, configFileInfluxDbAssert } = await import(
'./lib/assert/assert_config_file.js'
);

// Verify that config file is valid YAML
let resAssert = await configFileYamlAssert(globals.configFileExpanded);
if (resAssert === false) {
globals.logger.error('MAIN: Config file is not valid YAML. Exiting.');
process.exit(1);
} else {
globals.logger.info('MAIN: Config file is valid YAML - all good.');
}
let resAssert;

// Verify correct structure of config file
if (!settingsObj.options.skipConfigVerification) {
resAssert = await configFileStructureAssert(globals.config, globals.logger);
resAssert = await configFileStructureAssert();
if (resAssert === false) {
globals.logger.error('MAIN: Config file structure is incorrect. Exiting.');
process.exit(1);
Expand Down
9 changes: 9 additions & 0 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,9 @@ Butler:
teamsNotification:
reloadAppFailure:
enable: false
alertEnableByTag:
enable: false
tag: Butler - Send Teams alert if app reload fails
basicContentOnly: false
webhookURL: <URL to MS Teams webhook>

Expand All @@ -968,6 +971,9 @@ Butler:
slackNotification:
reloadAppFailure:
enable: false
alertEnableByTag:
enable: false
tag: Butler - Send Slack alert if app reload fails
basicContentOnly: false
webhookURL: <URL to Slack webhook>
channel: sense-task-failure # Slack channel to which task failure notifications are sent
Expand All @@ -985,6 +991,9 @@ Butler:
emailNotification:
reloadAppFailure:
enable: false # Enable/disable app reload failed notifications via email
alertEnableByTag:
enable: false
tag: Butler - Send email if app reload fails
appOwnerAlert:
enable: false # Should app owner get notification email (assuming email address is available in Sense)?
includeOwner:
Expand Down
Loading

0 comments on commit d1ebfaa

Please sign in to comment.