Einstellungen: Gitea-Actions-Variablen per API übernehmen (Token nur für den Abruf)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
RubenRWU
2026-10-15 15:36:35 +02:00
parent 7d8c226da2
commit b6165bc0b2
4 changed files with 190 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ from app.agent.workspace import is_personal
from app.db import get_db, session
from app.deps import actor, tenant_or_404
from app.models import Blob, ChatMessage, CoreRelease, Deployment, Secret, Setting, Tenant, Version
from app.services import contract, crypto, defaults, deploy, guard, llm, onyva_login, preflight, preview, releases, status as status_svc, store, tenants as tsvc
from app.services import contract, crypto, defaults, deploy, gitea_import, guard, llm, onyva_login, preflight, preview, releases, status as status_svc, store, tenants as tsvc
router = APIRouter(prefix="/api")
@@ -640,6 +640,21 @@ def tenants_status(refresh: bool = False):
# ── Einstellungen ───────────────────────────────────────────────────────────
@router.post("/gitea/variables")
def gitea_variables(body: dict = Body(...), db: Session = Depends(get_db)):
"""Liest die Gitea-Actions-Variablen (Klartext) und zeigt, was in den Einstellungen geändert würde. Der Token wird nicht gespeichert."""
token = str(body.get("token", "")).strip()
if not token:
raise HTTPException(400, "Token fehlt")
try:
vars_ = gitea_import.fetch_variables(str(body.get("url") or "https://gitea.onyva.dev"), str(body.get("repo", "")), token)
except gitea_import.GiteaError as exc:
raise HTTPException(400, str(exc))
except Exception as exc: # noqa: BLE001
raise HTTPException(502, f"Gitea nicht erreichbar: {type(exc).__name__}")
return {"count": len(vars_), "rows": gitea_import.preview(db, vars_)}
@router.get("/settings")
def get_settings(db: Session = Depends(get_db)):
return {s.key: s.value for s in db.scalars(select(Setting))}