Add base kubernetes support
This commit is contained in:
22
services/external/app/core/config.py
vendored
22
services/external/app/core/config.py
vendored
@@ -16,11 +16,23 @@ class DataSettings(BaseServiceSettings):
|
||||
# API Configuration
|
||||
API_V1_STR: str = "/api/v1"
|
||||
|
||||
# Override database URL to use EXTERNAL_DATABASE_URL
|
||||
DATABASE_URL: str = Field(
|
||||
default="postgresql+asyncpg://external_user:external_pass123@external-db:5432/external_db",
|
||||
env="EXTERNAL_DATABASE_URL"
|
||||
)
|
||||
# Database configuration (secure approach - build from components)
|
||||
@property
|
||||
def DATABASE_URL(self) -> str:
|
||||
"""Build database URL from secure components"""
|
||||
# Try complete URL first (for backward compatibility)
|
||||
complete_url = os.getenv("EXTERNAL_DATABASE_URL")
|
||||
if complete_url:
|
||||
return complete_url
|
||||
|
||||
# Build from components (secure approach)
|
||||
user = os.getenv("EXTERNAL_DB_USER", "external_user")
|
||||
password = os.getenv("EXTERNAL_DB_PASSWORD", "external_pass123")
|
||||
host = os.getenv("EXTERNAL_DB_HOST", "localhost")
|
||||
port = os.getenv("EXTERNAL_DB_PORT", "5432")
|
||||
name = os.getenv("EXTERNAL_DB_NAME", "external_db")
|
||||
|
||||
return f"postgresql+asyncpg://{user}:{password}@{host}:{port}/{name}"
|
||||
|
||||
# External API Configuration
|
||||
AEMET_API_KEY: str = os.getenv("AEMET_API_KEY", "")
|
||||
|
||||
Reference in New Issue
Block a user