Skip to content
Snippets Groups Projects
Commit e879bd14 authored by David Douard's avatar David Douard
Browse files

Rename the 'scrubber_db' config section as 'scrubber'

This is needed to make it compatible with swh.core's db upgrade tooling:
the name of the configuration section is exptected to be the swh module.
parent d9f89378
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
import os
from typing import Optional
import warnings
import click
......@@ -30,8 +31,8 @@ def scrubber_cli_group(ctx, config_file: Optional[str]) -> None:
Expected config format::
scrubber_db:
cls: local
scrubber:
cls: postgresql
db: "service=..." # libpq DSN
# for storage checkers + origin locator only:
......@@ -78,12 +79,20 @@ def scrubber_cli_group(ctx, config_file: Optional[str]) -> None:
ctx.ensure_object(dict)
ctx.obj["config"] = conf
if "scrubber_db" not in conf:
if "scrubber_db" in conf:
warnings.warn(
"the 'scrubber_db' configuration section has been renamed to 'scrubber'; "
f"please update your configuration file {config_file}",
DeprecationWarning,
)
conf["scrubber"] = conf.pop("scrubber_db")
if "scrubber" not in conf:
click.echo(
"WARNING: You must have a scrubber_db configured in your config file.\n"
"WARNING: You must have a scrubber configured in your config file.\n"
)
else:
ctx.obj["db"] = get_scrubber_db(**conf["scrubber_db"])
ctx.obj["db"] = get_scrubber_db(**conf["scrubber"])
@scrubber_cli_group.group(name="check")
......
......@@ -25,7 +25,7 @@ def invoke(
runner = CliRunner()
config = {
"scrubber_db": {"cls": "postgresql", "db": scrubber_db.conn.dsn},
"scrubber": {"cls": "postgresql", "db": scrubber_db.conn.dsn},
"graph": {"url": "http://graph.example.org:5009/"},
}
if storage:
......@@ -95,7 +95,7 @@ def test_help_check(mocker, scrubber_db, swh_storage):
scrubber_cli_group, ["check", "--help"], catch_exceptions=False
)
output = result.output.splitlines(keepends=False)
msg = "WARNING: You must have a scrubber_db configured in your config file."
msg = "WARNING: You must have a scrubber configured in your config file."
assert output[0] == msg
msg = "Usage: scrubber check [OPTIONS] COMMAND [ARGS]..."
assert output[2] == msg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment