Exemplo n.º 1
0
def config_fix(state: State):
    """Fix simple errors in esque config.

    Fixes simple errors like wrong current_contexts in the esque config when the configs was tampered with manually."""
    try:
        state.config.context_switch(state.config.current_context)
        click.echo("Your config seems fine. 🎉")
    except ValidationException:
        _cfg: Config = Config(disable_validation=True)
        if _cfg.current_context not in _cfg.available_contexts:
            click.echo(
                f"Found invalid current context. Switching context to state {_cfg.available_contexts[0]}."
            )
            _cfg.context_switch(_cfg.available_contexts[0])
            Config.set_instance(_cfg)
            state.config.save()
        else:
            click.echo(
                "Can't fix this configuration error try fixing it manually.")
Exemplo n.º 2
0
def config(config_version: int, load_config: config_loader):
    old_conf, _ = load_config(config_version)
    new_path, _ = migrate(Path(old_conf))
    Config.set_instance(Config())
    return Config.get_instance()
Exemplo n.º 3
0
def reload_config(load_config: config_loader, *, config: int = LOAD_INTEGRATION_TEST_CONFIG):
    conffile, _ = load_config(config)
    Config.set_instance(Config())
    return Config.get_instance()