feat: POLYGON_ENDPOINT — отдельная переменная, не трогает NUBES_API_TOKEN (v1.2.26)
This commit is contained in:
+13
-18
@@ -35,21 +35,19 @@ def get_token():
|
|||||||
def get_client():
|
def get_client():
|
||||||
"""HttpClient с автоопределением стенда.
|
"""HttpClient с автоопределением стенда.
|
||||||
|
|
||||||
Если NUBES_API_ENDPOINT — один из известных стендов (dev/test) →
|
Если POLYGON_ENDPOINT задан → направить ВСЕ запросы в polygon.
|
||||||
автоопределение через detect_endpoint().
|
Реальный NUBES_API_TOKEN остаётся нетронутым — polygon его не проверяет.
|
||||||
|
|
||||||
Если NUBES_API_ENDPOINT — любой другой URL (localhost, polygon, кастом) →
|
Иначе:
|
||||||
использовать его напрямую, без detect_endpoint().
|
- Если NUBES_API_ENDPOINT — известный стенд (STANDS) → detect_endpoint()
|
||||||
|
- Если кастомный URL → использовать напрямую
|
||||||
Это позволяет направить app-autotest в polygon:
|
|
||||||
NUBES_API_ENDPOINT=http://localhost:5000/api/v1/svc
|
|
||||||
или
|
|
||||||
NUBES_API_ENDPOINT=https://polygon.pythonk8s.dev.nubes.ru/api/v1/svc
|
|
||||||
"""
|
"""
|
||||||
|
polygon = current_app.config.get("POLYGON_ENDPOINT", "")
|
||||||
|
if polygon:
|
||||||
|
return HttpClient(polygon, get_token())
|
||||||
|
|
||||||
token = get_token()
|
token = get_token()
|
||||||
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||||
# Автоопределение ТОЛЬКО для известных стендов (dev/test).
|
|
||||||
# Для polygon/localhost/кастомных URL — используем endpoint как есть.
|
|
||||||
if endpoint in STANDS:
|
if endpoint in STANDS:
|
||||||
endpoint = detect_endpoint(token) or endpoint
|
endpoint = detect_endpoint(token) or endpoint
|
||||||
return HttpClient(endpoint, token)
|
return HttpClient(endpoint, token)
|
||||||
@@ -83,17 +81,14 @@ def get_client_id():
|
|||||||
def get_stand():
|
def get_stand():
|
||||||
"""Определить стенд (dev/test/mock) по активному токену.
|
"""Определить стенд (dev/test/mock) по активному токену.
|
||||||
|
|
||||||
Для известных стендов (STANDS) — автоопределение через detect_endpoint().
|
Если POLYGON_ENDPOINT задан → "polygon".
|
||||||
Для polygon/localhost — stand_name может вернуть "?" (неизвестный URL),
|
Иначе — автоопределение или stand_name."""
|
||||||
заменяем на "mock" чтобы трекер инстансов не сломался.
|
if current_app.config.get("POLYGON_ENDPOINT", ""):
|
||||||
|
return "polygon"
|
||||||
|
|
||||||
Примечание: для https://polygon.pythonk8s.dev.nubes.ru stand_name
|
|
||||||
вернёт "dev" (подстрока есть в URL) — это ок, трекер создаст
|
|
||||||
/tmp/instances-{clientId}-dev.json."""
|
|
||||||
token = get_token()
|
token = get_token()
|
||||||
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||||
if endpoint not in STANDS:
|
if endpoint not in STANDS:
|
||||||
# Неизвестный стенд — polygon или localhost
|
|
||||||
s = stand_name(endpoint)
|
s = stand_name(endpoint)
|
||||||
return s if s != "?" else "mock"
|
return s if s != "?" else "mock"
|
||||||
endpoint = detect_endpoint(token) or endpoint
|
endpoint = detect_endpoint(token) or endpoint
|
||||||
|
|||||||
+2
-1
@@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
|
|||||||
|
|
||||||
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
||||||
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
||||||
VERSION = "1.2.25"
|
VERSION = "1.2.26"
|
||||||
|
|
||||||
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
@@ -43,6 +43,7 @@ app.config["NUBES_API_ENDPOINT"] = os.getenv(
|
|||||||
"https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
"https://lk-api-gateway-test.ngcloud.ru/api/v1/svc"
|
||||||
)
|
)
|
||||||
app.config["NUBES_API_TOKEN"] = os.getenv("NUBES_API_TOKEN", "")
|
app.config["NUBES_API_TOKEN"] = os.getenv("NUBES_API_TOKEN", "")
|
||||||
|
app.config["POLYGON_ENDPOINT"] = os.getenv("POLYGON_ENDPOINT", "") # если задан → все запросы в polygon
|
||||||
app.config["VERSION"] = VERSION
|
app.config["VERSION"] = VERSION
|
||||||
|
|
||||||
# Регистрируем blueprint'ы — каждый отвечает за свою группу маршрутов
|
# Регистрируем blueprint'ы — каждый отвечает за свою группу маршрутов
|
||||||
|
|||||||
Reference in New Issue
Block a user