Open thejohnfreeman opened 9 years ago
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,
}
}))
@sampsyo any plan to support this? This would be an incredible addition in docker environment since its preferred to add config entries in docker compose files. Dynaconf does this exact thing, but for someone who already invested in confuse having this capability might be really helpful.
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.