"""환경변수 기반 설정 (스펙 §8). 사내망 TLS(self-signed CA) 대응을 처음부터 넣어둔다 — httpx 의 verify 인자에 CA 파일 경로 또는 bool 을 그대로 넘길 수 있게 ``tls_verify`` 로 변환한다. """ from __future__ import annotations from functools import lru_cache from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", extra="ignore" ) pulp_base_url: str = "http://localhost:8080" pulp_username: str = "admin" pulp_password: str = "" pulp_verify_tls: bool = True pulp_ca_file: str | None = None # 임시: 실제 Pulp 없이 가짜 데이터로 화면 확인 (단계5 전 제거 가능) pulp_demo: bool = False # 배포 감사 로그 (append-only JSONL) audit_log_path: str = "audit-log.jsonl" @lru_cache def get_settings() -> Settings: return Settings() def tls_verify(settings: Settings) -> str | bool: """httpx ``verify=`` 에 넘길 값. CA 파일 경로가 있으면 우선, 없으면 bool.""" if settings.pulp_ca_file: return settings.pulp_ca_file return settings.pulp_verify_tls