feat: интеграция с polygon — STANDS-check в get_client/get_stand (v1.2.24)
This commit is contained in:
+32
-9
@@ -18,7 +18,7 @@ import base64
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from flask import request, current_app
|
from flask import request, current_app
|
||||||
from api.http_client import HttpClient, detect_endpoint, stand_name
|
from api.http_client import HttpClient, detect_endpoint, stand_name, STANDS
|
||||||
|
|
||||||
|
|
||||||
def get_token():
|
def get_token():
|
||||||
@@ -33,12 +33,25 @@ def get_token():
|
|||||||
|
|
||||||
|
|
||||||
def get_client():
|
def get_client():
|
||||||
"""HttpClient с автоопределением стенда по активному токену.
|
"""HttpClient с автоопределением стенда.
|
||||||
|
|
||||||
Использует detect_endpoint() — пробует dev→test стенды.
|
Если NUBES_API_ENDPOINT — один из известных стендов (dev/test) →
|
||||||
Если автоопределение не сработало — fallback на NUBES_API_ENDPOINT из конфига."""
|
автоопределение через detect_endpoint().
|
||||||
|
|
||||||
|
Если 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
|
||||||
|
"""
|
||||||
token = get_token()
|
token = get_token()
|
||||||
endpoint = detect_endpoint(token) or current_app.config["NUBES_API_ENDPOINT"]
|
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)
|
return HttpClient(endpoint, token)
|
||||||
|
|
||||||
|
|
||||||
@@ -68,12 +81,22 @@ def get_client_id():
|
|||||||
|
|
||||||
|
|
||||||
def get_stand():
|
def get_stand():
|
||||||
"""Определить стенд (dev/test) по активному токену.
|
"""Определить стенд (dev/test/mock) по активному токену.
|
||||||
|
|
||||||
detect_endpoint → stand_name. Если автоопределение не сработало —
|
Для известных стендов (STANDS) — автоопределение через detect_endpoint().
|
||||||
fallback на NUBES_API_ENDPOINT из конфига."""
|
Для polygon/localhost — stand_name может вернуть "?" (неизвестный URL),
|
||||||
|
заменяем на "mock" чтобы трекер инстансов не сломался.
|
||||||
|
|
||||||
|
Примечание: для https://polygon.pythonk8s.dev.nubes.ru stand_name
|
||||||
|
вернёт "dev" (подстрока есть в URL) — это ок, трекер создаст
|
||||||
|
/tmp/instances-{clientId}-dev.json."""
|
||||||
token = get_token()
|
token = get_token()
|
||||||
endpoint = detect_endpoint(token) or current_app.config["NUBES_API_ENDPOINT"]
|
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
|
||||||
return stand_name(endpoint)
|
return stand_name(endpoint)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
|
|||||||
|
|
||||||
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
||||||
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
||||||
VERSION = "1.2.23"
|
VERSION = "1.2.24"
|
||||||
|
|
||||||
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
|
|||||||
Reference in New Issue
Block a user