diff --git a/site/app.py b/site/app.py index 95ec19e..6e07c06 100644 --- a/site/app.py +++ b/site/app.py @@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp # Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода. # Нужна для фильтрации истории (пользователь видит только записи своей версии). -VERSION = "1.2.26" +VERSION = "1.2.27" # Flask-приложение с Jinja2-шаблонами из папки templates/ app = Flask(__name__, template_folder="templates", static_folder="static") diff --git a/site/routes/api.py b/site/routes/api.py index c467d15..b04b28a 100644 --- a/site/routes/api.py +++ b/site/routes/api.py @@ -2,7 +2,7 @@ import threading from flask import Blueprint, current_app, jsonify, request -from api.http_client import create_client +from api.auth import get_client from runner import run_tests, get_status, load_config, save_config bp = Blueprint("api", __name__) @@ -11,10 +11,10 @@ bp = Blueprint("api", __name__) @bp.route("/api/run", methods=["POST"]) def api_run(): token = current_app.config["NUBES_API_TOKEN"] - result = create_client(token, current_app.config["NUBES_API_ENDPOINT"]) - if not result: + client = get_client() + endpoint = current_app.config["NUBES_API_ENDPOINT"] + if not client: return jsonify({"error": "Не удалось определить стенд"}), 500 - client, endpoint = result t = threading.Thread( target=run_tests, args=(endpoint, token), diff --git a/site/routes/main.py b/site/routes/main.py index c43a141..3f44f31 100644 --- a/site/routes/main.py +++ b/site/routes/main.py @@ -11,7 +11,7 @@ GET /api/operations/ — операции и autotest-инста from flask import Blueprint, current_app, render_template, request, make_response, jsonify, redirect from api.http_client import HttpClient, detect_endpoint, create_client, stand_name -from api.auth import get_token, get_client_id, get_token_info, get_token_masked +from api.auth import get_token, get_client_id, get_token_info, get_token_masked, get_client, get_stand from operations.get_instances import get_organization, get_instances from operations.get_services import get_services, get_service_detail from operations.service_list import load_service_ids @@ -105,11 +105,11 @@ def index(): config["service_ids"] = [] stand = "?" if active_token: - # create_client — автоопределение стенда + HttpClient - result = create_client(active_token, current_app.config["NUBES_API_ENDPOINT"]) - if result: - client, endpoint = result - stand = stand_name(endpoint) + # get_client — учитывает POLYGON_ENDPOINT + client = get_client() + endpoint = current_app.config["NUBES_API_ENDPOINT"] + stand = get_stand() + if client: try: # Организация — инстанс с serviceId=19 org = get_organization(client) @@ -168,11 +168,9 @@ def api_operations(svc_id): active_token = user_token or env_token try: - # Автоопределение стенда + HttpClient - result = create_client(active_token, current_app.config["NUBES_API_ENDPOINT"]) - if not result: - return jsonify({"error": "Не удалось определить стенд"}), 500 - client, endpoint = result + # get_client — учитывает POLYGON_ENDPOINT + client = get_client() + endpoint = current_app.config["NUBES_API_ENDPOINT"] # Детали сервиса: список операций (modify, delete, suspend, ...) detail = get_service_detail(client, svc_id) diff --git a/site/runner.py b/site/runner.py index 3c7483c..eb709c1 100644 --- a/site/runner.py +++ b/site/runner.py @@ -104,6 +104,11 @@ def run_tests(endpoint, token): endpoint: str — URL API token: str — JWT-токен""" global _current_run + # POLYGON_ENDPOINT проверяется в get_client(), здесь — прямой вызов для CLI + import os + polygon = os.getenv("POLYGON_ENDPOINT", "") + if polygon: + endpoint = polygon client = HttpClient(endpoint, token) config = load_config()