container
container
¶
Bottom-up container→state_dir resolution via podman annotations.
Shielded containers are launched with a terok.shield.state_dir
annotation that points at the per-container state directory written by
pre_start(). The OCI hook already reads that annotation out of the
runtime-provided OCI state JSON (see resources/hook_entrypoint.py).
This module does the same lookup for consumers that only have a
container name and no in-process ShieldConfig — the clearance
hub's verdict path, ad-hoc CLI invocations against a live container,
anything that enters from the podman side of the handoff rather than
from terok's task orchestration.
The annotation is the single source of truth for a shielded
container's state directory: both the OCI hook (via crun's stdin) and
the CLI (via this module) converge on the same string. In-process
callers (terok-sandbox.make_shield) supply state_dir at
construction and don't need to do a lookup.
On hosts where podman inspect isn't reachable (no podman on PATH,
no rootless user namespace, container simply doesn't exist), the
resolver returns None and callers fall back to whatever legacy
behaviour they had.
resolve_state_dir(container)
¶
Return the per-container state_dir from podman annotations, or None.
Calls podman inspect --format=json and pulls the
terok.shield.state_dir annotation out of the container's config.
Any failure — podman missing, container absent, annotation not set,
JSON malformed — collapses to None so callers can fall through.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
str
|
Container name or ID (short or full) as podman knows it. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
The resolved |
Path | None
|
otherwise |