fix: expand configured service usernames
This commit is contained in:
@@ -2,7 +2,7 @@ name: archive-control-archive
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
archive-client:
|
archive-client:
|
||||||
image: sodium/archive-clients:v0.1.0
|
image: sodium/archive-clients:v0.1.1
|
||||||
user: "1000:1000"
|
user: "1000:1000"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: ["--config", "/etc/archive-control/client.toml"]
|
command: ["--config", "/etc/archive-control/client.toml"]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: archive-control-cache
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
archive-client:
|
archive-client:
|
||||||
image: sodium/archive-clients:v0.1.0
|
image: sodium/archive-clients:v0.1.1
|
||||||
user: "1001:1001"
|
user: "1001:1001"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: archive-control-cache
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
archive-client:
|
archive-client:
|
||||||
image: sodium/archive-clients:v0.1.0
|
image: sodium/archive-clients:v0.1.1
|
||||||
user: "1001:1001"
|
user: "1001:1001"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ cache/archive routes according to policy.
|
|||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
archive-client:
|
archive-client:
|
||||||
image: sodium/archive-clients:v0.1.0
|
image: sodium/archive-clients:v0.1.1
|
||||||
user: "1001:1001"
|
user: "1001:1001"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: ["archive-client", "--config", "/etc/archive-control/client.toml"]
|
command: ["archive-client", "--config", "/etc/archive-control/client.toml"]
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "archive-clients"
|
name = "archive-clients"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = ["protobuf==7.35.1", "websockets==16.0"]
|
dependencies = ["protobuf==7.35.1", "websockets==16.0"]
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,8 @@ def _service(value: Any, name: str) -> ServiceConfig:
|
|||||||
username = value.get("username")
|
username = value.get("username")
|
||||||
if username is not None and (not isinstance(username, str) or not 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")
|
raise ConfigError(f"{name}.username must be a non-empty string")
|
||||||
|
if username is not None:
|
||||||
|
username = _expand(username)
|
||||||
addresses = value.get("advertised_addresses", [])
|
addresses = value.get("advertised_addresses", [])
|
||||||
if not isinstance(addresses, list) or any(
|
if not isinstance(addresses, list) or any(
|
||||||
not isinstance(address, str) or not address for address in addresses
|
not isinstance(address, str) or not address for address in addresses
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
from archive_clients.config import ClientConfig, ConfigError, RootMapping
|
from archive_clients.config import ClientConfig, ConfigError, RootMapping
|
||||||
|
|
||||||
@@ -18,10 +19,15 @@ class ConfigTests(unittest.TestCase):
|
|||||||
(root / "sync").mkdir()
|
(root / "sync").mkdir()
|
||||||
config_path = root / "client.toml"
|
config_path = root / "client.toml"
|
||||||
config_path.write_text(
|
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")
|
config = ClientConfig.load(config_path, "archive")
|
||||||
self.assertEqual(config.role, "archive")
|
self.assertEqual(config.role, "archive")
|
||||||
|
self.assertEqual(config.qbittorrent.username, "admin")
|
||||||
self.assertEqual(config.read_shared_token(), "token")
|
self.assertEqual(config.read_shared_token(), "token")
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
config.qbittorrent.roots.api_to_local("/downloads/a/b"),
|
config.qbittorrent.roots.api_to_local("/downloads/a/b"),
|
||||||
|
|||||||
Reference in New Issue
Block a user