-
Notifications
You must be signed in to change notification settings - Fork 29
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
Environment variable override support #136
Comments
Extended proposal
This is not trivial to parse strings like this but it would be a very useful feature. Arrays are likely going to be required to make environment variables a useful way to override configuration, but objects are quite useless if you can just make multiple qualifying environment variables, so do not need to be implemented. Either way, languages like TOML may it impossible to do things this way, so I'm really unsure how easy it will be to make it support the user's chosen markup, or if JSON should be the only option here. |
yes, that would be a nice feature to offer! Thank you for the proposal. |
Alright so a little change to the proposal (I'm not familiar with clap and don't know if that has its own, better semantics for this) Arrays in environment variables should not be parsed like that but instead should be lists separated with semicolons ( An array containing objects should be achievable by passing the users' configuration language in, i.e. this is what it would look like to pass an object in: Given they are using a language that requires new lines, etc for this, escape codes can be used directly, and if the semicolon would normally be parsed by the language (a lot of these languages don't define start and EOF like JSON), it can be escaped too, i.e. with YAML:
name: Mr Raffin
age: ~ name: Mechite
age: 127 I feel like using objects/documents in environment variables is a very rare use case, but having support for it is ideal, and I think having a standard way of defining arrays is better simply because they are going to be used every often, e.g: |
Implementary notes
Should be available on builder classes, etc, as configuration options for loading configurations.
Expected behaviour
When a qualifier in the configuration, e.g.
server.port
is set as an environment variable (should be case insensitive), it should be the preferred value in the configuration when this feature is enabled. If the environment variable cannot be parsed correctly when requested, by anObjectConverter
or by aget*
method, the value from the configuration file is used as a fallback.Motivation
night-config
provides a great way for efficiency in development environments, especially with auto updating, etc.Large, scalable environments tend to prefer environment variables for configuration, e.g. Docker on k8s.
The text was updated successfully, but these errors were encountered: