feat: gated deploy with preview, audit log, rollback trail (stage 4)
- pulp_client: create_publication / update_distribution / wait_for_task
- GET /repos/{uuid}/deploy/confirm: 미리보기(현재→대상, 순 변화) + type-to-confirm 모달
- POST /repos/{uuid}/deploy: 검증 게이트(서버측 재확인) → publication 생성 →
distribution 교체 → 감사 로그. 2단계 실패 시 '운영망 변경 여부' 명확화
- audit.record_deploy: 누가/언제/repo/이전버전→대상버전 JSONL (롤백 추적)
- 배포 버튼은 검증 통과 + 미배포 버전만 활성, 성공 시 버전목록 OOB 갱신
- 인증은 TODO (operator placeholder, 배포 비밀번호 재확인 예정)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
app/views.py
32
app/views.py
@@ -85,14 +85,44 @@ def build_version_view(
|
||||
호출부에서 repo 의 gpg_status() 를 주입한다.
|
||||
"""
|
||||
number = version_number(version.get("pulp_href"))
|
||||
is_deployed = number is not None and number == deployed_number
|
||||
# 배포 가능: 검증 통과(pass) + 현재 배포 중이 아님 (스펙 §5-2 게이트)
|
||||
deployable = (gpg or {}).get("level") == "pass" and not is_deployed
|
||||
return {
|
||||
"number": number,
|
||||
"href": version.get("pulp_href"),
|
||||
"created": version.get("pulp_created"),
|
||||
"package_count": _content_count(version, "present"),
|
||||
"added": _content_count(version, "added"),
|
||||
"removed": _content_count(version, "removed"),
|
||||
"gpg": gpg,
|
||||
"is_deployed": number is not None and number == deployed_number,
|
||||
"is_deployed": is_deployed,
|
||||
"deployable": deployable,
|
||||
}
|
||||
|
||||
|
||||
def deploy_preview(
|
||||
version_views: list[dict[str, Any]],
|
||||
target_number: int | None,
|
||||
deployed_number: int | None,
|
||||
) -> dict[str, Any]:
|
||||
"""배포 확인 모달용 미리보기: 현재 운영 버전 → 대상 버전, 순 패키지 변화."""
|
||||
|
||||
def find(n: int | None) -> dict[str, Any] | None:
|
||||
return next((v for v in version_views if v["number"] == n), None)
|
||||
|
||||
current = find(deployed_number)
|
||||
target = find(target_number)
|
||||
current_count = current["package_count"] if current else 0
|
||||
target_count = target["package_count"] if target else 0
|
||||
net = target_count - current_count
|
||||
return {
|
||||
"current_version": deployed_number,
|
||||
"current_count": current_count,
|
||||
"target_version": target_number,
|
||||
"target_count": target_count,
|
||||
"net": abs(net),
|
||||
"net_sign": "+" if net >= 0 else "−",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user