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

loading a specific "path" of a config file and/or loading multiple of them #8

Closed
RonnyPfannschmidt opened this issue Jul 6, 2022 · 3 comments

Comments

@RonnyPfannschmidt
Copy link

i have a setup where we are using dynaconf style environment

which means that instead of

myconfig:
   host: abc
   port: 1337

we have something like

# settings.yaml
default:
  myconfig:
     port: 1337
prod:
  myconfig:
    host: danger.example.com
qe:
  myconfig:
     host: qe.hidden.example.com

then the full config ought to be created via something like

# first rough draft, please destroy :)
def load_config(current_env="qe"):
   setting = Config.from_path("settings.yaml")
   local = Config.from_path("setting.local.yaml", optional=True)
   return merge_from_environments(configs=[settings, local], environments=["global", "default", current_env])
@cjw296
Copy link
Member

cjw296 commented Jul 6, 2022

Can you provide some pseudocode for merge_from_environments?

@RonnyPfannschmidt
Copy link
Author

def merge_from_environments(configs, environments):
   merged = Config()
   for environment in environments:
     for config in configs:
        merged += Config(config.get(environment, {})
   return merged

@cjw296
Copy link
Member

cjw296 commented Jul 7, 2022

Great to chat yesterday, as discussed, if you can implement this one in your code base (without stuff that can be added when #9 is done!) then we can see about lifting it back into configurator as a pattern once its stable.

Closing this for now, but please comment so we can re-open if you hit problems doing this, or when it's time to bring it upstream.

@cjw296 cjw296 closed this as completed Jul 7, 2022
@cjw296 cjw296 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2022
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

2 participants