Skip to main content

Module containers

Module containers 

Source

Structs§

ContainerCacheEntry
A cached container listing for a single host.
ContainerError
Error from a container listing operation. Preserves the detected runtime even when the ps command fails so it can be cached for future calls.
ContainerInfo
Metadata for a single container (from docker ps -a / podman ps -a).

Enums§

ContainerAction
Actions that can be performed on a container.
ContainerRuntime
Supported container runtimes.

Functions§

container_action_command
Build the shell command to perform an action on a container.
container_list_command
Build the SSH command string for listing containers.
fetch_containers
Fetch container list synchronously via SSH. Follows the fetch_remote_listing pattern.
format_relative_time
Format a Unix timestamp as a human-readable relative time string.
load_container_cache
Load container cache from ~/.purple/container_cache.jsonl. Malformed lines are silently ignored. Duplicate aliases: last-write-wins.
parse_container_cache_content
Parse container cache from JSONL content string (for demo/test use).
parse_container_output
Parse the stdout of a container listing command.
parse_container_ps
Parse NDJSON output from docker ps --format '{{json .}}'. Invalid lines are silently ignored (MOTD lines, blank lines, etc.).
parse_runtime
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.
save_container_cache
Save container cache to ~/.purple/container_cache.jsonl via atomic write.
spawn_container_action
Spawn a background thread to perform a container action (start/stop/restart). Validates the container ID before executing.
spawn_container_listing
Spawn a background thread to fetch container listings. Follows the spawn_remote_listing pattern.
truncate_str
Truncate a string to at most max characters. Appends “..” if truncated.
validate_container_id
Validate a container ID or name. Accepts ASCII alphanumeric, hyphen, underscore, dot. Rejects empty, non-ASCII, shell metacharacters, colon.