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():
|
||||
"""HttpClient с автоопределением стенда.
|
||||
|
||||
Если NUBES_API_ENDPOINT — один из известных стендов (dev/test) →
|
||||
автоопределение через detect_endpoint().
|
||||
Если POLYGON_ENDPOINT задан → направить ВСЕ запросы в polygon.
|
||||
Реальный NUBES_API_TOKEN остаётся нетронутым — polygon его не проверяет.
|
||||
|
||||
Если NUBES_API_ENDPOINT — любой другой URL (localhost, polygon, кастом) →
|
||||
использовать его напрямую, без detect_endpoint().
|
||||
|
||||
Это позволяет направить app-autotest в polygon:
|
||||
NUBES_API_ENDPOINT=http://localhost:5000/api/v1/svc
|
||||
или
|
||||
NUBES_API_ENDPOINT=https://polygon.pythonk8s.dev.nubes.ru/api/v1/svc
|
||||
Иначе:
|
||||
- Если NUBES_API_ENDPOINT — известный стенд (STANDS) → detect_endpoint()
|
||||
- Если кастомный URL → использовать напрямую
|
||||
"""
|
||||
polygon = current_app.config.get("POLYGON_ENDPOINT", "")
|
||||
if polygon:
|
||||
return HttpClient(polygon, get_token())
|
||||
|
||||
token = get_token()
|
||||
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||
# Автоопределение ТОЛЬКО для известных стендов (dev/test).
|
||||
# Для polygon/localhost/кастомных URL — используем endpoint как есть.
|
||||
if endpoint in STANDS:
|
||||
endpoint = detect_endpoint(token) or endpoint
|
||||
return HttpClient(endpoint, token)
|
||||
@@ -83,17 +81,14 @@ def get_client_id():
|
||||
def get_stand():
|
||||
"""Определить стенд (dev/test/mock) по активному токену.
|
||||
|
||||
Для известных стендов (STANDS) — автоопределение через detect_endpoint().
|
||||
Для polygon/localhost — stand_name может вернуть "?" (неизвестный URL),
|
||||
заменяем на "mock" чтобы трекер инстансов не сломался.
|
||||
Если POLYGON_ENDPOINT задан → "polygon".
|
||||
Иначе — автоопределение или stand_name."""
|
||||
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()
|
||||
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||
if endpoint not in STANDS:
|
||||
# Неизвестный стенд — polygon или localhost
|
||||
s = stand_name(endpoint)
|
||||
return s if s != "?" else "mock"
|
||||
endpoint = detect_endpoint(token) or endpoint
|
||||
|
||||
Reference in New Issue
Block a user