Expand pipeline panes and select the verified Docker client endpoint

This commit is contained in:
2026-10-10 00:56:55 +01:00
parent 2cc703b8a5
commit 7565693957
13 changed files with 352 additions and 8 deletions
+53 -2
View File
@@ -6,6 +6,8 @@ import ipaddress
import re
import shutil
import json
import os
import tempfile
from pathlib import Path
import subprocess
import sys
@@ -215,11 +217,60 @@ printf 'header = "Authorization: Bearer %s"\\n' "$(cat "$PIPELINES_NTFY_TOKEN_FI
print("Phone reception is not verified by this setup check.")
address = self.compose("port", "pipelines", "8080", capture=True).stdout.strip()
port = address.rsplit(":", 1)[-1]
if not port.isdigit():
if not port.isdigit() or not 1 <= int(port) <= 65535:
raise ValueError("Could not identify the published Pipelines port")
print(f"Host CLI/TUI connection: pipelines --url ws://127.0.0.1:{port}/connect tui")
endpoint = f"ws://127.0.0.1:{port}/connect"
self.verify_host_endpoint(endpoint)
self.configure_client(endpoint)
print(f"Host CLI/TUI connection: pipelines --url {endpoint} tui")
print("Install host client binaries with ./install.sh --native if needed.")
def verify_host_endpoint(self, endpoint):
if shutil.which("go"):
command = ["go", "run", "./cmd/pipelines", "--url", endpoint, "status", "--json"]
elif shutil.which("pipelines"):
command = [shutil.which("pipelines"), "--url", endpoint, "status", "--json"]
else:
print("Host-side server connection not tested: no host Go or pipelines CLI available.")
return
result = self.runner(command, cwd=self.directory, capture_output=True, text=True, timeout=60)
try:
status = json.loads(result.stdout)
except ValueError:
raise ValueError("Host client could not inspect the published Docker server; setup is NOT complete")
if (result.returncode or not isinstance(status, dict)
or not isinstance(status.get("ntfy"), dict)
or status["ntfy"].get("health") != "healthy"):
raise ValueError("Host client did not reach the verified ntfy-enabled Docker server; check the published port before using the TUI")
print("Verified: host client reaches the ntfy-enabled Docker server at " + endpoint)
def configure_client(self, endpoint):
root = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home()/".config")
directory = root/"pipelines"
path = directory/"client.json"
if path.is_symlink():
raise ValueError("Refusing to modify symlinked client.json; use the printed --url explicitly")
existing = json.loads(path.read_text()) if path.exists() else {}
if not isinstance(existing, dict):
raise ValueError("client.json must contain an object; existing configuration was not replaced")
existing["server_url"] = endpoint
directory.mkdir(mode=0o700, parents=True, exist_ok=True)
temporary = None
try:
with tempfile.NamedTemporaryFile(mode="w", dir=directory, delete=False) as file:
temporary = Path(file.name)
os.chmod(temporary, 0o600)
json.dump(existing, file, indent=2)
file.write("\n")
os.replace(temporary, path)
finally:
if temporary is not None:
temporary.unlink(missing_ok=True)
print(f"Saved Docker client default: {endpoint} ({path}). Restart the TUI.")
override = os.environ.get("PIPELINES_URL", "")
if override and override != endpoint:
print("WARNING: PIPELINES_URL overrides the saved Docker address. Use the printed --url or update that variable; otherwise the TUI may still reach a different server.")
def run(self, args):
self.compose("version", capture=True)
self.settings(args)