stack-orchestrator/app/data/config/watcher-azimuth/merge-toml.js
Nabarun Gogoi 960a24c96b Add stack for azimuth watchers with gateway-server (#379)
* Setup gateway-server with watchers

* Add js script to merge toml config files

* Remove individual watcher configs

* Add all azimuth watchers in stack

* Fix toml-js install

* Use env variables for ipld-eth-server endpoints

* Checkout to version tag in azimuth-watcher-ts repo

Former-commit-id: 5a94aed7f7
2023-05-04 15:35:04 +05:30

32 lines
1.1 KiB
JavaScript

const fs = require('fs');
const tomlJS = require('toml-js');
const toml = require('toml');
const { merge } = require('lodash')
const main = () => {
const overrideConfigString = fs.readFileSync('environments/watcher-config.toml', 'utf-8');
const configString = fs.readFileSync('environments/local.toml', 'utf-8');
const overrideConfig = toml.parse(overrideConfigString)
const config = toml.parse(configString)
// Merge configs
const updatedConfig = merge(config, overrideConfig);
// Form dbConnectionString for jobQueue DB
const parts = config.jobQueue.dbConnectionString.split("://");
const credsAndDB = parts[1].split("@");
const creds = credsAndDB[0].split(":");
creds[0] = overrideConfig.database.username;
creds[1] = overrideConfig.database.password;
credsAndDB[0] = creds.join(":");
const dbName = credsAndDB[1].split("/")[1]
credsAndDB[1] = [overrideConfig.database.host, dbName].join("/");
parts[1] = credsAndDB.join("@");
updatedConfig.jobQueue.dbConnectionString = parts.join("://");
fs.writeFileSync('environments/local.toml', tomlJS.dump(updatedConfig), 'utf-8');
}
main();