feat(containers-dashboard): voeg host_ip toe aan gepubliceerde poorten en corrigeer portweergave
This commit is contained in:
+1
-1
@@ -3,5 +3,5 @@ WORKDIR /app
|
||||
RUN apt-get update && apt-get install -y curl systemd && rm -rf /var/lib/apt/lists/*
|
||||
RUN pip install fastapi uvicorn requests-unixsocket pyyaml pytest httpx
|
||||
COPY app.py .
|
||||
COPY tests/ ./tests/
|
||||
#COPY tests/ ./tests/
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
||||
|
||||
@@ -439,6 +439,31 @@ def find_defined_containers():
|
||||
defined[name] = rel
|
||||
return defined
|
||||
|
||||
def _extract_published_ports(container: dict) -> list[str]:
|
||||
"""
|
||||
Normalize Podman API Ports into a stable display list:
|
||||
- "127.0.0.1:8080:8000/tcp"
|
||||
- "8080:8000/tcp" (if no host ip)
|
||||
"""
|
||||
out: list[str] = []
|
||||
for p in (container.get("Ports") or []):
|
||||
host_ip = p.get("host_ip") or p.get("HostIp") or ""
|
||||
host_port = p.get("host_port") or p.get("HostPort")
|
||||
cont_port = p.get("container_port") or p.get("ContainerPort")
|
||||
proto = p.get("protocol") or p.get("Protocol") or ""
|
||||
|
||||
if host_port is None or cont_port is None:
|
||||
continue
|
||||
|
||||
s = ""
|
||||
if host_ip:
|
||||
s += f"{host_ip}:"
|
||||
s += f"{host_port}:{cont_port}"
|
||||
if proto:
|
||||
s += f"/{proto}"
|
||||
out.append(s)
|
||||
|
||||
return out
|
||||
|
||||
@app.get("/containers-dashboard")
|
||||
def containers_dashboard():
|
||||
@@ -449,6 +474,7 @@ def containers_dashboard():
|
||||
for c in real:
|
||||
_ensure_container_status_field(c)
|
||||
c["_dashboard_source"] = "podman"
|
||||
c["_dashboard_published_ports"] = _extract_published_ports(c)
|
||||
dashboard.append(c)
|
||||
|
||||
# B) Dedup set (HOTFIX 3.3) — exact extraction, no sorting
|
||||
|
||||
Reference in New Issue
Block a user