Example #1
0
    def test_load_sources(self):
        fc = FlexConfig()
        data = [{"a": 1, "b": {"c": 2}}, {"a": 3, "b": {"d": 4}}]
        fc.load_sources(data)
        fc.load_sources({"e": 5})

        assert fc == {"a": 3, "b": {"c": 2, "d": 4}, "e": 5}
def get_config(override: Dict[str, Any] = None, prompt_db_creds: bool = False) -> FlexConfig:
    """ Get the app config for this  """
    global _app_config

    if _app_config:
        return _app_config

    if not override:
        override = {}

    _app_config = FlexConfig()
    _app_config.load_sources([default_config, EnvSource("{{ cookiecutter.module_name | upper }}_"), YAMLSource(yaml_path), override])

    env = _app_config["env"]
    if env != "local":
        _app_config.load_sources(AWSSource(f"{{ cookiecutter.module_name }}/{env}"))

    if prompt_db_creds:  # pragma: no cover
        username = input("Username: "******"(mysql\+pymysql://)\S+:\S+(@.*)", fr"\1{username}:{password}\2", _app_config["database_url"]
        )
        _app_config["database_url"] = main_url

    return _app_config
Example #3
0
def get_config(override: Dict[str, Any] = None) -> FlexConfig:
    """ Get the app config for this  """
    global _app_config

    if _app_config:
        return _app_config

    if not override:
        override = {}

    _app_config = FlexConfig()
    _app_config.load_sources([
        default_config,
        EnvSource("APP_"),
        YAMLSource(yaml_path),
        override,
    ])

    env = _app_config["env"]
    if env != "local":
        _app_config.load_sources(AWSSource(f"app/{env}"))

    return _app_config