Release v2.0.4

This commit is contained in:
Christian 2026-01-28 10:41:48 +01:00
parent 3543a9b079
commit 08b7abbeea
5 changed files with 34 additions and 10 deletions

View File

@ -8,7 +8,7 @@
# RELEASE VERSION
# =====================================================
# Tag fra Gitea (f.eks. v1.0.0, v1.2.3)
RELEASE_VERSION=v2.0.3
RELEASE_VERSION=v2.0.4
# =====================================================
# GITEA AUTHENTICATION

8
RELEASE_NOTES_v2.0.4.md Normal file
View File

@ -0,0 +1,8 @@
# Release Notes v2.0.4
## Fixes
- Reworked the migration execution endpoint to stream SQL files via stdin instead of relying on chained shell commands, which broke on Podman/Docker setups and led to pattern-matching errors for some files.
- Added a default `CONTAINER_RUNTIME` setting so the endpoint knows whether to run `docker` or `podman` when the env var is not provided.
---
Release Date: 28. januar 2026

View File

@ -1 +1 @@
2.0.3
2.0.4

View File

@ -147,6 +147,7 @@ class Settings(BaseSettings):
POSTGRES_PASSWORD: str = "bmc_hub"
POSTGRES_DB: str = "bmc_hub"
POSTGRES_PORT: int = 5432
CONTAINER_RUNTIME: str = "docker"
RELEASE_VERSION: str = "latest"
GITEA_URL: str = "https://g.bmcnetworks.dk"
GITHUB_TOKEN: str = ""

View File

@ -8,7 +8,7 @@ from fastapi import APIRouter, Request, HTTPException
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel
import shlex
import os
import subprocess
from app.core.config import settings
@ -65,15 +65,30 @@ def execute_migration(payload: MigrationExecution):
raise HTTPException(status_code=404, detail="Migration file not found")
# Determine the container runtime (Podman or Docker)
container_runtime = "podman" if settings.CONTAINER_RUNTIME == "podman" else "docker"
runtime = settings.CONTAINER_RUNTIME.lower()
if runtime not in {"docker", "podman"}:
runtime = "docker"
# Execute the migration file
command = (
f"cat {shlex.quote(str(migration_file))} | "
f"{container_runtime} exec -i bmc-hub-postgres "
f"psql -U {settings.POSTGRES_USER} -d {settings.POSTGRES_DB}"
command = [
runtime,
"exec",
"-i",
"bmc-hub-postgres",
"psql",
"-U",
settings.POSTGRES_USER,
"-d",
settings.POSTGRES_DB,
]
migration_sql = migration_file.read_text()
result = subprocess.run(
command,
input=migration_sql,
capture_output=True,
text=True,
env={**os.environ, "PGPASSWORD": settings.POSTGRES_PASSWORD},
)
result = subprocess.run(command, shell=True, capture_output=True, text=True)
if result.returncode != 0:
raise HTTPException(status_code=500, detail=f"Migration failed: {result.stderr}")