diff --git a/swh/vault/api/server.py b/swh/vault/api/server.py --- a/swh/vault/api/server.py +++ b/swh/vault/api/server.py @@ -67,13 +67,13 @@ raise EnvironmentError( "The vault backend can only be started with a 'local' configuration", ) - args = vcfg["args"] + args = vcfg.get("args", {}) if "cache" not in args: - args["cache"] = cfg.get("cache") + args["cache"] = vcfg.get("cache", cfg.get("cache")) if "storage" not in args: - args["storage"] = cfg.get("storage") + args["storage"] = vcfg.get("storage", cfg.get("storage")) if "scheduler" not in args: - args["scheduler"] = cfg.get("scheduler") + args["scheduler"] = vcfg.get("scheduler", cfg.get("scheduler")) for key in ("cache", "storage", "scheduler"): if not args.get(key): diff --git a/swh/vault/cookers/__init__.py b/swh/vault/cookers/__init__.py --- a/swh/vault/cookers/__init__.py +++ b/swh/vault/cookers/__init__.py @@ -49,7 +49,8 @@ raise EnvironmentError( "This vault backend can only be a 'remote' configuration" ) - args = vcfg["args"] + + args = vcfg.get("args", {}) if "storage" not in args: args["storage"] = cfg.get("storage") diff --git a/swh/vault/tests/conftest.py b/swh/vault/tests/conftest.py --- a/swh/vault/tests/conftest.py +++ b/swh/vault/tests/conftest.py @@ -73,7 +73,7 @@ @pytest.fixture def swh_local_vault_config(swh_vault_config: Dict[str, Any]) -> Dict[str, Any]: return { - "vault": {"cls": "local", "args": swh_vault_config}, + "vault": {"cls": "local", **swh_vault_config}, "client_max_size": 1024 ** 3, } diff --git a/swh/vault/tests/test_init_cookers.py b/swh/vault/tests/test_init_cookers.py --- a/swh/vault/tests/test_init_cookers.py +++ b/swh/vault/tests/test_init_cookers.py @@ -63,7 +63,6 @@ ValueError, "invalid configuration: missing 'storage' config entry", ), - ({"vault": {"cls": "remote"}}, KeyError, "args",), ], ) def test_get_cooker_config_ko( @@ -94,6 +93,10 @@ "vault": {"cls": "remote", "args": {"url": "mock://vault-backend",},}, "storage": {"cls": "remote", "url": "mock://storage-url"}, }, + { + "vault": {"cls": "remote", "url": "mock://vault-backend",}, + "storage": {"cls": "remote", "url": "mock://storage-url"}, + }, ], ) def test_get_cooker_nominal(config_ok, tmp_path, monkeypatch): diff --git a/swh/vault/tests/test_server.py b/swh/vault/tests/test_server.py --- a/swh/vault/tests/test_server.py +++ b/swh/vault/tests/test_server.py @@ -114,9 +114,9 @@ @pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) def test_check_config_missing_key(missing_key, swh_vault_config) -> None: """Any other configuration than 'local' (the default) is rejected""" - config_ok = {"vault": {"cls": "local", "args": swh_vault_config}} + config_ok = {"vault": {"cls": "local", **swh_vault_config}} config_ko = copy.deepcopy(config_ok) - config_ko["vault"]["args"].pop(missing_key, None) + config_ko["vault"].pop(missing_key, None) expected_error = f"invalid configuration: missing {missing_key} config entry" with pytest.raises(ValueError, match=expected_error): @@ -126,5 +126,5 @@ @pytest.mark.parametrize("missing_key", ["storage", "cache", "scheduler"]) def test_check_config_ok(missing_key, swh_vault_config) -> None: """Any other configuration than 'local' (the default) is rejected""" - config_ok = {"vault": {"cls": "local", "args": swh_vault_config}} + config_ok = {"vault": {"cls": "local", **swh_vault_config}} assert check_config(config_ok) is not None