feat: добавлена пометка типа операции (Build/Push) в истории сборок Dockerfile

- Добавлена колонка 'Тип' во все таблицы истории сборок
- Для push операций отображается registry вместо платформ
- Сохранение пользователя при создании push лога
- Исправлена ошибка с logger в push_docker_image endpoint
- Улучшено отображение истории сборок с визуальными индикаторами
This commit is contained in:
Сергей Антропов
2026-02-15 22:59:02 +03:00
parent 23e1a6037b
commit 1fbf9185a2
232 changed files with 38075 additions and 5 deletions

View File

@@ -0,0 +1,86 @@
"""
API endpoints для экспорта ролей
Автор: Сергей Антропов
Сайт: https://devops.org.ru
"""
from fastapi import APIRouter, Request, HTTPException, Form
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.templating import Jinja2Templates
from pathlib import Path
from typing import List, Optional
import json
from app.core.config import settings
from app.services.export_service import ExportService
router = APIRouter()
templates_path = Path(__file__).parent.parent.parent.parent / "templates"
templates = Jinja2Templates(directory=str(templates_path))
export_service = ExportService()
@router.get("/roles/{role_name}/export", response_class=HTMLResponse)
async def export_role_page(request: Request, role_name: str):
"""Страница экспорта роли"""
# Проверка существования роли
roles_dir = settings.PROJECT_ROOT / "roles" / role_name
if not roles_dir.exists():
raise HTTPException(status_code=404, detail=f"Роль '{role_name}' не найдена")
# Получение доступных компонентов
components = export_service.get_role_components(role_name)
return templates.TemplateResponse(
"pages/roles/export.html",
{
"request": request,
"role_name": role_name,
"components": components
}
)
@router.post("/api/v1/roles/{role_name}/export")
async def export_role_api(
role_name: str,
repo_url: str = Form(...),
branch: str = Form("main"),
version: Optional[str] = Form(None),
components: str = Form(""), # JSON строка
include_secrets: bool = Form(False),
commit_message: Optional[str] = Form(None)
):
"""API endpoint для экспорта роли"""
try:
# Парсинг компонентов
components_list = []
if components:
components_list = json.loads(components)
# Запуск экспорта через Celery (в будущем)
# Пока синхронно
result = await export_service.export_role(
role_name=role_name,
repo_url=repo_url,
branch=branch,
version=version,
components=components_list if components_list else None,
include_secrets=include_secrets,
commit_message=commit_message
)
return JSONResponse(content=result, status_code=200)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
except Exception as e:
raise HTTPException(status_code=500, detail=f"Ошибка при экспорте роли: {str(e)}")
@router.get("/api/v1/roles/{role_name}/export/components")
async def get_role_components_api(role_name: str):
"""Получение списка компонентов роли"""
try:
components = export_service.get_role_components(role_name)
return {"components": components}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))