Files
devops-portal/backend/pipeline_migrate.py
2026-04-10 01:46:19 +03:00

30 lines
985 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Миграция черновика конвейера: плоский список фаз → этапы (стенды) с фазами и проверками."""
from __future__ import annotations
import uuid
from typing import Any
def migrate_definition(defn: Any) -> dict:
"""Приводит definition к schema_version 2 с ключом stages."""
if not isinstance(defn, dict):
return {"schema_version": 2, "stages": []}
if defn.get("stages"):
return defn
phases = defn.get("phases") or []
if not phases:
return {"schema_version": 2, "stages": []}
return {
"schema_version": 2,
"stages": [
{
"id": str(uuid.uuid4()),
"name": "Этап 1",
"description": "Импорт: ранее фазы задавались без этапов (стендов).",
"checks": [],
"phases": phases,
}
],
}