Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested config over environment variables #238

Closed
strarsis opened this issue Oct 10, 2016 · 6 comments
Closed

Nested config over environment variables #238

strarsis opened this issue Oct 10, 2016 · 6 comments

Comments

@strarsis
Copy link

How can I pass nested configuration over environment variables?
What delimiter can I use for separating keys?
It would be helpful when an example is added to documentation.

@strarsis
Copy link
Author

strarsis commented Oct 14, 2016

Colons (:) cause trouble/aren't possible in environment variable names.

I found a tutorial page where environment variables with separator are used: http://www.codedependant.net/2015/01/31/production-ready-node-configuration/

This example allows to use environment variables with double underscore (__) separator:

[...]
nconf
  .env({separator:'__'}) 
[...]

With this setting, an environment variable for nested config

export db__host="test"

equals to config key with default colon (:) delimiter

db:host="test"

@simonrenoult
Copy link

This feature is already mentioned in the documentation: https://github.com/indexzero/nconf#env

@Redsandro
Copy link

Colons (:) cause trouble

@strarsis the trouble causing colon seems arbitrary; in some situations they work fine: #336. Have you figured out why they sometimes don't work?

Sorry for bumping an old issue. Google brought me here. It is still relevant.

@linqFR
Copy link

linqFR commented Nov 22, 2020

This feature is already mentioned in the documentation: https://github.com/indexzero/nconf#env

Hello
well to be honest : the explanation is not clear !

  • will .env('--' ) change separator only for env store or all stores?
    i tried many ways and so far just seems to work on env !

  • how do i change default separator for files or in memory ?

  • will the new separator always work for .required()?

  • I saw some explanation over internet about env({separator:'xx',whitelist:['blah','bloah']}) : can you explain/document more in details? Is this working also for file && memory stores?

@mhamann
Copy link
Collaborator

mhamann commented Nov 24, 2020

I agree--this feature doesn't necessarily work how you might expect. This PR is a breaking change, but I think makes it clearer. Feedback welcome: #337

@linqFR
Copy link

linqFR commented Nov 24, 2020

@mhamann
thank you

what about .required() and whitelist?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants