fix: create_client → get_client — POLYGON_ENDPOINT в main/api/runner (v1.2.27)
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ from routes.api_scenario_defs import bp_defs as api_scenario_defs_bp
|
|||||||
|
|
||||||
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
# Версия — показывается в топбаре UI. Меняется при КАЖДОМ изменении кода.
|
||||||
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
# Нужна для фильтрации истории (пользователь видит только записи своей версии).
|
||||||
VERSION = "1.2.26"
|
VERSION = "1.2.27"
|
||||||
|
|
||||||
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
# Flask-приложение с Jinja2-шаблонами из папки templates/
|
||||||
app = Flask(__name__, template_folder="templates", static_folder="static")
|
app = Flask(__name__, template_folder="templates", static_folder="static")
|
||||||
|
|||||||
+4
-4
@@ -2,7 +2,7 @@ import threading
|
|||||||
|
|
||||||
from flask import Blueprint, current_app, jsonify, request
|
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
|
from runner import run_tests, get_status, load_config, save_config
|
||||||
|
|
||||||
bp = Blueprint("api", __name__)
|
bp = Blueprint("api", __name__)
|
||||||
@@ -11,10 +11,10 @@ bp = Blueprint("api", __name__)
|
|||||||
@bp.route("/api/run", methods=["POST"])
|
@bp.route("/api/run", methods=["POST"])
|
||||||
def api_run():
|
def api_run():
|
||||||
token = current_app.config["NUBES_API_TOKEN"]
|
token = current_app.config["NUBES_API_TOKEN"]
|
||||||
result = create_client(token, current_app.config["NUBES_API_ENDPOINT"])
|
client = get_client()
|
||||||
if not result:
|
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||||
|
if not client:
|
||||||
return jsonify({"error": "Не удалось определить стенд"}), 500
|
return jsonify({"error": "Не удалось определить стенд"}), 500
|
||||||
client, endpoint = result
|
|
||||||
t = threading.Thread(
|
t = threading.Thread(
|
||||||
target=run_tests,
|
target=run_tests,
|
||||||
args=(endpoint, token),
|
args=(endpoint, token),
|
||||||
|
|||||||
+9
-11
@@ -11,7 +11,7 @@ GET /api/operations/<svc_id> — операции и autotest-инста
|
|||||||
from flask import Blueprint, current_app, render_template, request, make_response, jsonify, redirect
|
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.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_instances import get_organization, get_instances
|
||||||
from operations.get_services import get_services, get_service_detail
|
from operations.get_services import get_services, get_service_detail
|
||||||
from operations.service_list import load_service_ids
|
from operations.service_list import load_service_ids
|
||||||
@@ -105,11 +105,11 @@ def index():
|
|||||||
config["service_ids"] = []
|
config["service_ids"] = []
|
||||||
stand = "?"
|
stand = "?"
|
||||||
if active_token:
|
if active_token:
|
||||||
# create_client — автоопределение стенда + HttpClient
|
# get_client — учитывает POLYGON_ENDPOINT
|
||||||
result = create_client(active_token, current_app.config["NUBES_API_ENDPOINT"])
|
client = get_client()
|
||||||
if result:
|
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||||
client, endpoint = result
|
stand = get_stand()
|
||||||
stand = stand_name(endpoint)
|
if client:
|
||||||
try:
|
try:
|
||||||
# Организация — инстанс с serviceId=19
|
# Организация — инстанс с serviceId=19
|
||||||
org = get_organization(client)
|
org = get_organization(client)
|
||||||
@@ -168,11 +168,9 @@ def api_operations(svc_id):
|
|||||||
active_token = user_token or env_token
|
active_token = user_token or env_token
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Автоопределение стенда + HttpClient
|
# get_client — учитывает POLYGON_ENDPOINT
|
||||||
result = create_client(active_token, current_app.config["NUBES_API_ENDPOINT"])
|
client = get_client()
|
||||||
if not result:
|
endpoint = current_app.config["NUBES_API_ENDPOINT"]
|
||||||
return jsonify({"error": "Не удалось определить стенд"}), 500
|
|
||||||
client, endpoint = result
|
|
||||||
|
|
||||||
# Детали сервиса: список операций (modify, delete, suspend, ...)
|
# Детали сервиса: список операций (modify, delete, suspend, ...)
|
||||||
detail = get_service_detail(client, svc_id)
|
detail = get_service_detail(client, svc_id)
|
||||||
|
|||||||
@@ -104,6 +104,11 @@ def run_tests(endpoint, token):
|
|||||||
endpoint: str — URL API
|
endpoint: str — URL API
|
||||||
token: str — JWT-токен"""
|
token: str — JWT-токен"""
|
||||||
global _current_run
|
global _current_run
|
||||||
|
# POLYGON_ENDPOINT проверяется в get_client(), здесь — прямой вызов для CLI
|
||||||
|
import os
|
||||||
|
polygon = os.getenv("POLYGON_ENDPOINT", "")
|
||||||
|
if polygon:
|
||||||
|
endpoint = polygon
|
||||||
client = HttpClient(endpoint, token)
|
client = HttpClient(endpoint, token)
|
||||||
config = load_config()
|
config = load_config()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user