Skip to content

Commit 27a43d3

Browse files
author
ci bot
committed
Merge branch 'fix/TG-1064-config-env-port-precedence' into 'enterprise'
fix(standalone): honor config.env for ports, hosts, and base URLs See merge request dkinternal/testgen/dataops-testgen!504
2 parents c1baa0e + e28d5a8 commit 27a43d3

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

testgen/settings.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def _ssl_files_present() -> bool:
474474
return bool(SSL_CERT_FILE) and os.path.isfile(SSL_CERT_FILE) and bool(SSL_KEY_FILE) and os.path.isfile(SSL_KEY_FILE)
475475

476476

477-
_ui_tls_env = os.getenv("TG_UI_TLS_ENABLED", "").lower()
477+
_ui_tls_env = getenv("TG_UI_TLS_ENABLED", "").lower()
478478
UI_TLS_ENABLED: bool = _ui_tls_env in ("yes", "true") if _ui_tls_env else _ssl_files_present()
479479
"""
480480
Enable TLS for the Streamlit UI server.
@@ -484,7 +484,7 @@ def _ssl_files_present() -> bool:
484484
defaults to: auto-detect
485485
"""
486486

487-
_api_tls_env = os.getenv("TG_API_TLS_ENABLED", "").lower()
487+
_api_tls_env = getenv("TG_API_TLS_ENABLED", "").lower()
488488
API_TLS_ENABLED: bool = _api_tls_env in ("yes", "true") if _api_tls_env else _ssl_files_present()
489489
"""
490490
Enable TLS for the API/MCP server (uvicorn).
@@ -568,23 +568,23 @@ def _ssl_files_present() -> bool:
568568
defaults to: `yes`
569569
"""
570570

571-
UI_PORT: int = int(os.getenv("TG_UI_PORT", "8501"))
571+
UI_PORT: int = int(getenv("TG_UI_PORT", "8501"))
572572
"""
573573
Port for the UI server.
574574
575575
from env variable: `TG_UI_PORT`
576576
defaults to: `8501`
577577
"""
578578

579-
API_PORT: int = int(os.getenv("TG_API_PORT", "8530"))
579+
API_PORT: int = int(getenv("TG_API_PORT", "8530"))
580580
"""
581581
Port for the API server.
582582
583583
from env variable: `TG_API_PORT`
584584
defaults to: `8530`
585585
"""
586586

587-
API_HOST: str = os.getenv("TG_API_HOST", "0.0.0.0") # noqa: S104
587+
API_HOST: str = getenv("TG_API_HOST", "0.0.0.0") # noqa: S104
588588
"""
589589
Host for the API server.
590590
@@ -597,7 +597,7 @@ def _default_base_url() -> str:
597597
return f"{scheme}://localhost:{API_PORT}"
598598

599599

600-
BASE_URL: str = os.getenv("TG_BASE_URL", "") or _default_base_url()
600+
BASE_URL: str = getenv("TG_BASE_URL", "") or _default_base_url()
601601
"""
602602
Externally-reachable base URL for the API/MCP/OAuth server.
603603
@@ -608,14 +608,13 @@ def _default_base_url() -> str:
608608

609609
def _default_ui_base_url() -> str:
610610
scheme = "https" if UI_TLS_ENABLED else "http"
611-
port = os.getenv("STREAMLIT_SERVER_PORT", "8501")
612-
return f"{scheme}://localhost:{port}"
611+
return f"{scheme}://localhost:{UI_PORT}"
613612

614613

615-
UI_BASE_URL: str = os.getenv("TG_UI_BASE_URL", "") or _default_ui_base_url()
614+
UI_BASE_URL: str = getenv("TG_UI_BASE_URL", "") or _default_ui_base_url()
616615
"""
617616
Externally-reachable base URL for the Streamlit UI (used in email links, PDFs).
618617
619618
from env variable: `TG_UI_BASE_URL`
620-
defaults to: computed from UI_TLS_ENABLED and STREAMLIT_SERVER_PORT
619+
defaults to: computed from UI_TLS_ENABLED and UI_PORT
621620
"""

0 commit comments

Comments
 (0)