MVP: config.yaml, pipeline runner, API routes, UI with checkboxes and run button
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import threading
|
||||
|
||||
from flask import Blueprint, current_app, jsonify, request
|
||||
|
||||
from runner import run_tests, get_status, load_config, save_config
|
||||
|
||||
bp = Blueprint("api", __name__)
|
||||
|
||||
|
||||
@bp.route("/api/run", methods=["POST"])
|
||||
def api_run():
|
||||
t = threading.Thread(
|
||||
target=run_tests,
|
||||
args=(current_app.config["NUBES_API_ENDPOINT"], current_app.config["NUBES_API_TOKEN"]),
|
||||
daemon=True,
|
||||
)
|
||||
t.start()
|
||||
return jsonify({"ok": True})
|
||||
|
||||
|
||||
@bp.route("/api/status")
|
||||
def api_status():
|
||||
return jsonify(get_status() or {})
|
||||
|
||||
|
||||
@bp.route("/api/config", methods=["GET"])
|
||||
def api_config_get():
|
||||
return jsonify(load_config())
|
||||
|
||||
|
||||
@bp.route("/api/config", methods=["POST"])
|
||||
def api_config_save():
|
||||
save_config(request.get_json())
|
||||
return jsonify({"ok": True})
|
||||
+5
-1
@@ -3,6 +3,7 @@ from flask import Blueprint, current_app, render_template, request, make_respons
|
||||
from api.http_client import HttpClient
|
||||
from operations.get_instances import get_organization, get_instances
|
||||
from operations.get_services import get_services, get_service_detail
|
||||
from runner import load_config
|
||||
|
||||
bp = Blueprint("main", __name__)
|
||||
|
||||
@@ -43,6 +44,7 @@ def index():
|
||||
|
||||
services = []
|
||||
instances = []
|
||||
config = {}
|
||||
if active_token:
|
||||
try:
|
||||
client = HttpClient(
|
||||
@@ -55,6 +57,7 @@ def index():
|
||||
instances = get_instances(client)
|
||||
# org first, then rest
|
||||
instances.sort(key=lambda i: (0 if i.get("serviceId") == 19 else 1, i.get("displayName", "")))
|
||||
config = load_config()
|
||||
except Exception as e:
|
||||
error = str(e)
|
||||
|
||||
@@ -63,7 +66,8 @@ def index():
|
||||
env_token_masked=_mask(env_token),
|
||||
has_user_token=bool(user_token),
|
||||
services=services,
|
||||
instances=instances)
|
||||
instances=instances,
|
||||
config=config)
|
||||
|
||||
|
||||
@bp.route("/api/operations/<int:svc_id>")
|
||||
|
||||
Reference in New Issue
Block a user