Files
pulp-console/app/config.py
Hyemin Lee aef4124da0 refactor: audit log to Postgres + split /healthz liveness from Pulp status
- audit.record_deploy 를 JSONL 파일 → Postgres deploy_audit 테이블로 (재배포 휘발 방지)
  - psycopg 지연 import, _write 는 테스트에서 monkeypatch 지점, DATABASE_URL 사용
  - 감사 기록 실패는 배포 완료를 막지 않고 UI 경고(audit_ok)
- /healthz: Pulp 무관 라이브니스 {"ok":true} (컨테이너 health check),
  Pulp 연결 배지는 /pulp-status 로 분리 (대시보드가 폴링)
- config: DATABASE_URL 추가, audit_log_path 제거

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 13:42:11 +09:00

40 lines
1.2 KiB
Python

"""환경변수 기반 설정 (스펙 §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 없이 가짜 데이터로 화면 확인
pulp_demo: bool = False
# 배포 감사 로그 저장용 Postgres (MANUAL: 제공 DB). 없으면 감사 기록 불가.
database_url: str | None = None
@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