Good afternoon,
i currently have a FLY.toml file and an .ENV file, both of them have the same env variables, is there a way to have a single source of truth?
Kind Regards
Alym
Good afternoon,
i currently have a FLY.toml file and an .ENV file, both of them have the same env variables, is there a way to have a single source of truth?
Kind Regards
Alym
If you’re using NodeJS you can modify the dotenv variables with your own variables, check out how this module does it:
var dotenv = require('dotenv')
var dotenvExpand = require('dotenv-expand')
// first they load the .env file
var myEnv = dotenv.config()
// and then they modified the variables in myEnv.parsed
// and overwrote process.env with the processed variables
dotenvExpand.expand(myEnv)
It should be really easy to replace their “expand” function with something that loads in values from a toml file instead -
function expand (config) {
// if ignoring process.env, use a blank object
const environment = config.ignoreProcessEnv ? {} : process.env
for (const configKey in config.parsed) {
const value = Object.prototype.hasOwnProperty.call(environment, configKey) ? environment[configKey] : config.parsed[configKey]
config.parsed[configKey] = _interpolate(value, environment, config)
}
for (const processKey in config.parsed) {
environment[processKey] = config.parsed[processKey]
}
return config
}