-
Notifications
You must be signed in to change notification settings - Fork 54
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
configuration from environment variables #10
Comments
Sounds good! |
One important caveat is that most shells have a limited character set for environment variable names. Usually the OS will support all non null characters, but shells will only support letters, numbers, and underscores. I think that will translate to only allowing overrides of variables with "well behaved names". |
That should be easy to implement yourself due to good code design of confuse. You can combine layers of data gathered from different sources. from confuse import RootView, ConfigSource
c = RootView([])
# Higher priority first
c.add(ConfigSource.of({
'corn': 300,
'potato': 200,
'berries': ['blue', 'red'],
'map': {
'x': 3,
'y': 4,
}
}))
# Lower priority last
c.add(ConfigSource.of({
'banana': 150,
'apple': 240,
'corn': 200,
'berries': ['green', 'purple'],
'map': {
'y': 6,
'z': 5,
'm': 1,
}
})) |
I would be happy to review a PR, but I do not have the bandwidth to implement this myself. |
There should be a function to generate a configuration from environment variables. Overriding configuration in the environment is handy for
sys.argv
(e.g. logging and security modules).I believe Confit already supports an optional environment variable naming a configuration path. That's good, but I'd extend it to be a colon-separated path (like PATH, CLASSPATH, or PYTHONPATH) of configurations to load in order.
The text was updated successfully, but these errors were encountered: