fix: expand configured service usernames
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
+1
-1
@@ -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"]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
)
|
||||
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"),
|
||||
|
||||
Reference in New Issue
Block a user