feat(cli): hosts describe reads the container live - #166
Conversation
hosts describe repeated four fields from the state file. It now reads the container from Docker and the route from the proxy: image, status with uptime from docker ps, the port and backend Traefik routes to from its API (so VIRTUAL_HOST and traefik.* labels are treated the same), the container's networks, whether a request through the proxy with that Host header is answered, its mounts, and its command with secrets redacted by flag name, by assignment name and in URL userinfo, never by the shape of a value. The reachability probe goes through the proxy's published port rather than to the container address, which on Docker Desktop is inside the VM. A record whose container is gone is reported as such and the command fails. hosts list is unchanged and still reads the state file alone. Closes: #164 Assisted-by: claude-code/claude-fable-5-1
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Refs: #164 Assisted-by: claude-code/claude-fable-5-1
…, parse the port from the authority
A quoted assignment such as API_TOKEN='live secret' was redacted up to
the first space only, leaving part of the value visible. Quoted forms
now get their own substitutions, as the flag forms already had. A rule
written as Host("x") reaches the API with escaped double quotes and was
not matched, so a label-routed container could show no backend. An
already provider-qualified service name is no longer qualified twice.
The routed port is parsed from the URL authority, so a backend without
an explicit port yields no port rather than a fragment of the host.
Refs: #164
Assisted-by: claude-code/claude-fable-5-1
Refs: #164 Assisted-by: claude-code/claude-fable-5-1
User description
Closes #164. The layout is the one settled in the issue.
What changes
hosts describe <hostname>reads the container from Docker and the route from the proxy instead of repeating four state-file fields.hosts listis unchanged and still reads the state file alone, with nodocker inspectper row.Real output on p620:
How each field is read
docker inspect --formatcalls. Uptime comes fromdocker ps --format '{{.Status}}', so there is no date arithmetic and no BSD versus GNU split. Mount fields are separated by\x1fin the template because a bind has no name andreadcollapses adjacent tabs.VIRTUAL_HOSTand for nativetraefik.*labels, so the label-routed case needs no separate logic.Hostheader, with a 5s timeout. On Docker Desktop the container address is inside the VM and would report no answer from the host.--auth,--token,--password,--secret,--api-keyand similar, bare, quoted or--flag=value), by assignment name (*_TOKEN=,*_SECRET=, ...) and in URL userinfo. Never by the shape of a value, and the README says a value passed some other way is printed as is.Cases
traefik.* labels, port N.backendandreachablesay so instead of failing.Verification
test/test.sh: the hosts suite gains stubs fordockerandcurland asserts the live fields, the same-path bind and named volume rendering, the redaction of four planted secrets, the label-routed form, and the gone-container failure. 19/19 locally, run as the suite does (sourcingbin/lib/hosts.shalone).shellcheck -xon the CLI and libraries: the same four pre-existing findings asmain.docker runcontainer onbridgeand a compose container on its own network.PR Type
Enhancement, Tests, Documentation
Description
Inspect live containers for detailed host metadata
Resolve Traefik backends and probe proxy reachability
Redact command secrets and handle missing containers
Document behavior and expand CLI coverage
Diagram Walkthrough
File Walkthrough
hosts.sh
Read host container details from live servicesbin/lib/hosts.sh
test.sh
Test live host description and secret redactiontest/test.sh
CHANGELOG.md
Record live hosts describe functionalityCHANGELOG.md
hosts describecontainer reporting.README.md
Document live container host descriptionsREADME.md