-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
52 lines (38 loc) · 1.4 KB
/
config.py
File metadata and controls
52 lines (38 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""Runtime configuration helpers for SightLine backend modules."""
from __future__ import annotations
import os
DEFAULT_GOOGLE_CLOUD_PROJECT = "sightline-hackathon"
DEFAULT_GOOGLE_CLOUD_REGION = "us-central1"
DEFAULT_SESSION_DB_URL = "sqlite:///sightline_sessions.db"
def _get_env(name: str, default: str) -> str:
value = os.getenv(name)
if value is None:
return default
trimmed = value.strip()
return trimmed or default
def get_google_cloud_project() -> str:
"""Return the configured Google Cloud project ID."""
return _get_env("GOOGLE_CLOUD_PROJECT", DEFAULT_GOOGLE_CLOUD_PROJECT)
def get_google_cloud_region() -> str:
"""Return the configured Google Cloud region.
``GOOGLE_CLOUD_LOCATION`` remains supported for backwards compatibility
with current deployment configuration.
"""
region = os.getenv("GOOGLE_CLOUD_REGION", "").strip()
if region:
return region
location = os.getenv("GOOGLE_CLOUD_LOCATION", "").strip()
if location:
return location
return DEFAULT_GOOGLE_CLOUD_REGION
def get_session_db_url() -> str:
"""Return the configured session database URL."""
return _get_env("SESSION_DB_URL", DEFAULT_SESSION_DB_URL)
__all__ = [
"DEFAULT_GOOGLE_CLOUD_PROJECT",
"DEFAULT_GOOGLE_CLOUD_REGION",
"DEFAULT_SESSION_DB_URL",
"get_google_cloud_project",
"get_google_cloud_region",
"get_session_db_url",
]