diff --git a/deploy/production/lithium/compose.yaml b/deploy/production/lithium/compose.yaml index 93239b9..80504ff 100644 --- a/deploy/production/lithium/compose.yaml +++ b/deploy/production/lithium/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-archive services: archive-client: - image: sodium/archive-clients:v0.1.0 + image: sodium/archive-clients:v0.1.1 user: "1000:1000" restart: unless-stopped command: ["--config", "/etc/archive-control/client.toml"] diff --git a/deploy/production/x1/compose.yaml b/deploy/production/x1/compose.yaml index 6ca27c3..e81d3e4 100644 --- a/deploy/production/x1/compose.yaml +++ b/deploy/production/x1/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-cache services: archive-client: - image: sodium/archive-clients:v0.1.0 + image: sodium/archive-clients:v0.1.1 user: "1001:1001" restart: unless-stopped network_mode: host diff --git a/deploy/production/x2/compose.yaml b/deploy/production/x2/compose.yaml index 167589c..7a4603c 100644 --- a/deploy/production/x2/compose.yaml +++ b/deploy/production/x2/compose.yaml @@ -2,7 +2,7 @@ name: archive-control-cache services: archive-client: - image: sodium/archive-clients:v0.1.0 + image: sodium/archive-clients:v0.1.1 user: "1001:1001" restart: unless-stopped network_mode: host diff --git a/docs/deployment-and-usage.md b/docs/deployment-and-usage.md index 38db01f..dbf9a26 100644 --- a/docs/deployment-and-usage.md +++ b/docs/deployment-and-usage.md @@ -213,7 +213,7 @@ cache/archive routes according to policy. ```yaml services: archive-client: - image: sodium/archive-clients:v0.1.0 + image: sodium/archive-clients:v0.1.1 user: "1001:1001" restart: unless-stopped command: ["archive-client", "--config", "/etc/archive-control/client.toml"] diff --git a/pyproject.toml b/pyproject.toml index 3d99a2d..a349f9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "archive-clients" -version = "0.1.0" +version = "0.1.1" requires-python = ">=3.11" dependencies = ["protobuf==7.35.1", "websockets==16.0"] diff --git a/src/archive_clients/config.py b/src/archive_clients/config.py index 0377aad..af64ea3 100644 --- a/src/archive_clients/config.py +++ b/src/archive_clients/config.py @@ -169,6 +169,8 @@ def _service(value: Any, name: str) -> ServiceConfig: username = value.get("username") if username is not None and (not isinstance(username, str) or not username): raise ConfigError(f"{name}.username must be a non-empty string") + if username is not None: + username = _expand(username) addresses = value.get("advertised_addresses", []) if not isinstance(addresses, list) or any( not isinstance(address, str) or not address for address in addresses diff --git a/tests/test_config.py b/tests/test_config.py index dbb273c..2dedf72 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,6 +2,7 @@ import os import tempfile import unittest from pathlib import Path +from unittest.mock import patch from archive_clients.config import ClientConfig, ConfigError, RootMapping @@ -18,10 +19,15 @@ class ConfigTests(unittest.TestCase): (root / "sync").mkdir() config_path = root / "client.toml" config_path.write_text( - _config(root, role="cache"), encoding="utf-8" + _config(root, role="cache").replace( + 'username = "admin"', 'username = "${QB_USER}"' + ), + encoding="utf-8", ) - config = ClientConfig.load(config_path, "archive") + with patch.dict(os.environ, {"QB_USER": "admin"}): + config = ClientConfig.load(config_path, "archive") self.assertEqual(config.role, "archive") + self.assertEqual(config.qbittorrent.username, "admin") self.assertEqual(config.read_shared_token(), "token") self.assertEqual( config.qbittorrent.roots.api_to_local("/downloads/a/b"),