A cached container listing for a single host. engine_version is the
daemon’s Server.Version captured during the last refresh, surfaced in
the host detail panel; None means the version sub-call did not return
or the cache was written by an older purple build.
Parsed subset of docker inspect <id> (or podman inspect). Only the
fields purple’s container detail panel renders are extracted; the rest
of the JSON document is discarded so cache size stays bounded.
Parsed result of a container listing command. engine_version is the
daemon’s Server.Version (best-effort, None when the version sub-call
failed or the remote runtime predates the engine sentinel).
Build the SSH command string for listing containers. Output is the
container NDJSON, then the ##purple:engine## sentinel, then the
daemon version on its own line. The version subcall is suffixed with
|| true so its failure cannot mask a docker ps error: the chain
surfaces ps’s exit code, while a missing version line just yields
engine_version: None downstream.
Translate a non-zero docker/podman exit code into a short
human-readable hint. Returns None for codes without a well-known
meaning so the UI can fall back to the bare number. Exit 0 has no
entry because the detail panel only annotates failed exits.
Sources: docker docs + Linux signal table.
Synchronously fetch logs and split into lines. Returns the raw
captured stdout split on \n so the renderer does not have to
re-parse. Empty trailing lines are dropped.
Format a Unix timestamp as a human-readable relative time string.
Honours demo_flag::now_secs() when demo mode is active so visual
regression goldens stay byte-stable across long-running test
processes (same pattern as history::format_time_ago).
Format a duration in seconds as a compact label (12s, 5m,
2h, 3d). Used for the in-border staleness badge where width
is precious and the surrounding label (synced) already says
“ago” without the suffix.
Parse docker inspect <id> stdout into ContainerInspect. The command
always returns a JSON array; we take the first element. Missing fields
degrade to defaults rather than fail so a partial response still
renders something useful.
Parse NDJSON output from docker ps --format '{{json .}}' or
podman ps --format '{{json .}}'. Used by tests and the public
crate API exposed via lib.rs; the live SSH path streams through
parse_container_output directly, so the binary build sees this
helper as unused and the lint must be silenced.
Detect runtime from command output by matching the LAST non-empty trimmed
line. Only “docker” or “podman” are accepted. MOTD-resilient.
Currently unused (sentinel-based detection handles this inline) but kept
as a public utility for potential future two-step detection paths.
Parse a Docker Up … status string into a compact uptime label.
Returns None for any non-running state (Exited, Created, Restarting,
Paused without an Up prefix, empty). Cells render <1m for
sub-minute uptimes, 1m / 5m / 12h / 5w / 3mo / 2y otherwise.
Format follows Docker’s units.HumanDuration.
Spawn a background thread to run container logs. Same shape as
spawn_container_inspect_listing. In demo mode the SSH call is
short-circuited with a deterministic synthetic log stream so the
logs viewer (and its / search) is exercisable without a remote.