generated from coulomb/repo-seed
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""Application configuration loaded from environment variables.
|
|
|
|
All settings are read from environment variables prefixed with
|
|
``ARTIFACTSTORE_``. A ``.env`` file at the repository root is honoured for
|
|
local development; see ``.env.example``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Top-level service configuration."""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_prefix="ARTIFACTSTORE_",
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
database_url: str = "sqlite+aiosqlite:///./var/artifactstore.db"
|
|
storage_local_root: str = "./var/storage"
|
|
log_level: str = "INFO"
|
|
auth_tokens: str = ""
|
|
anon_read: bool = False
|
|
api_url: str = "http://127.0.0.1:8000"
|
|
api_token: str = ""
|
|
retention_config_path: str = ""
|
|
retention_sweep_interval_seconds: int = 3600
|
|
|
|
@property
|
|
def bearer_tokens(self) -> frozenset[str]:
|
|
"""Configured shared-secret bearer tokens, parsed from CSV / newline text."""
|
|
return frozenset(
|
|
token.strip()
|
|
for token in self.auth_tokens.replace("\n", ",").split(",")
|
|
if token.strip()
|
|
)
|
|
|
|
|
|
def get_settings() -> Settings:
|
|
"""Return a freshly-loaded :class:`Settings` instance."""
|
|
return Settings()
|