Loading app/main.py +12 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os import re import tempfile from http import HTTPStatus from typing import Optional import boto3 from botocore.config import Config Loading Loading @@ -83,8 +84,17 @@ def guess_env_ctx() -> str: return "REVIEW" def get_var(env_ctx: str, var_suffix: str) -> str: return os.getenv(f"AWS_{env_ctx}_{var_suffix}") or os.getenv(f"AWS_{var_suffix}") def get_var(env_ctx: str, var_suffix: str) -> Optional[str]: return getenv_checked(f"AWS_{env_ctx}_{var_suffix}") or getenv_checked(f"AWS_{var_suffix}") # Workaround the GitLab bug with forced exposed variables: # variables: # SOMEVAR: "$SOMEVAR" # os.getenv("SOMEVAR") may have value '$SOMEVAR' if the variable is not defined as a project variable def getenv_checked(name: str) -> Optional[str]: value = os.getenv(name) return None if value == f"${name}" else value @app.get("/ping", response_class=PlainTextResponse) Loading Loading
app/main.py +12 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os import re import tempfile from http import HTTPStatus from typing import Optional import boto3 from botocore.config import Config Loading Loading @@ -83,8 +84,17 @@ def guess_env_ctx() -> str: return "REVIEW" def get_var(env_ctx: str, var_suffix: str) -> str: return os.getenv(f"AWS_{env_ctx}_{var_suffix}") or os.getenv(f"AWS_{var_suffix}") def get_var(env_ctx: str, var_suffix: str) -> Optional[str]: return getenv_checked(f"AWS_{env_ctx}_{var_suffix}") or getenv_checked(f"AWS_{var_suffix}") # Workaround the GitLab bug with forced exposed variables: # variables: # SOMEVAR: "$SOMEVAR" # os.getenv("SOMEVAR") may have value '$SOMEVAR' if the variable is not defined as a project variable def getenv_checked(name: str) -> Optional[str]: value = os.getenv(name) return None if value == f"${name}" else value @app.get("/ping", response_class=PlainTextResponse) Loading