rwynn / monstache

a go daemon that syncs MongoDB to Elasticsearch in realtime. you know, for search.
https://rwynn.github.io/monstache-site/
MIT License
1.28k stars 181 forks source link

How to use environment file with .toml file #411

Open Bhanu220290 opened 4 years ago

Bhanu220290 commented 4 years ago

Hi Rwynn, I haven't find any document/reference in your monstache advance regarding how to make env(environment) file and communicate/pass the data to .toml file. First I explain my issue: Right now i have 2 environment staging and production and in both environment we just have minimal difference in .toml file so here we just take input from stack-holder and use them, few fields are like database name , db url, collection name and elasticsearch url and I have one script(transformation) where i am taking data from one collection and push the data in Elasticsearch .now the problem here is , i have to hardcode these things in script and toml file so is there any ways to achieve my goal?

rwynn commented 3 years ago

Hi @Bhanu220290 sorry I must have missed this issue. If you go to https://rwynn.github.io/monstache-site/config/ and search on env var name you should see the environment variable names that you can set to keep the values out of the configuration file. Please let me know if you have any issues using those.

DazDotOne commented 2 years ago

Hi @rwynn, Firstly thanks for the awesome project. I'm jumping on this issue rather than start a new one as it seems to be the same question.

I'm just wondering whether this works as a hybrid?

If I define for instance, my mongo url and elastic urls/user/password as environment variables. Does it merge them with any values provided in the config.toml file?

Or does it need to be one approach or the other?

Thanks.

rwynn commented 2 years ago

You can combine them.

Command line arguments take precedence over environment variables which in turn take precedence over the TOML config file. You can verify the final configuration used by Monstache by running monstache with -print-config.

DazDotOne commented 2 years ago

Thanks @rwynn

Again, awesome tool dude!