Skip to content

feat(facts.podman): add more basic facts - #1900

Open
lsg551 wants to merge 2 commits into
pyinfra-dev:3.xfrom
lsg551:feat/facts/podman/extend-basic-facts
Open

feat(facts.podman): add more basic facts#1900
lsg551 wants to merge 2 commits into
pyinfra-dev:3.xfrom
lsg551:feat/facts/podman/extend-basic-facts

Conversation

@lsg551

@lsg551 lsg551 commented Jul 25, 2026

Copy link
Copy Markdown

Description

The facts for Podman as of now (v3.9.2) include two basic facts:

  1. podman.PodmanPs to list the existing running/exited/... containers (equivalent to podman ps -a)
  2. podman.PodmanSystemInfo to get Podman system information (=podman system info)

This PR extends this list with the following new facts:

  1. .PodmanImages to get the output from podman image ls / list
    container image in the local storage
  2. .PodmanVolumes similarly lists volumes
  3. .PodmanPods lists pods
  4. .PodmanQuadlets lists quadlets files (podman quadlet list, available since Podman v5.6.0)
  5. .PodmanNetworks lists podman networks

Nothing fancy, it just (like the existing two) wraps the Podman CLI and forwards the JSON output.

Checklist

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)
  • Pull request title follows the
    conventional commits format

Caveats

  • I wasn't sure how exceptions should be handled in fact processing. The existing code seems to be inconsistent and mostly lets the exception propagate / using asserts. I decided to wrap any exception raised while fact processing in the FactProcessError. Let me know what's the preference here.
  • The podman quadlet <cmd> stuff was only recently added in Podman v5.6.0 (published 2025-08-15). The new fact podman.PodmanQuadlets is using this and would fail if this version constraint is not met. I added a note in the docstring. If this is desired, I could also implement an internal version check based on the existing facts (which would still cause a failure but point the user to the exact root cause...). (But I don't know where/how exactly - yet.)

PS: sorry if I should have opened an issue before (the contributing guidelines did not mention this though)

lsg551 added 2 commits July 25, 2026 20:16
This commit adds to the 2 existing Podman facts (.PodmanPs to list
containers and .PodmanSystemInfo for podman system information) the
following new facts:

1. .PodmanImages to get the output from `podman image ls` / list
container image in the local storage
2. .PodmanVolumes similarly lists volumes
3. .PodmanPods lists pods
4. .PodmanQuadlets lists quadlets files (`podman quadlet list`,
available since Podman v5.6.0)
5. .PodmanNetworks lists podman networks, including the default bridge
Updated the docstrings of facts for `podman.PodmanPs` and
`podman.PodmanSystemInfo`. 7390979 added a few more basic facts for
Podman; their writing style is slightly different and includes examples.
The commit aligns the existing ones with the new ones.
@wowi42 wowi42 added the facts Issues with facts. label Jul 26, 2026

@wowi42 wowi42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, the helper and the docstring examples are good. One blocker:

PodmanNetworks.process contains leftover debug code that writes test_podman.json to the current working directory on every fact call. I checked out the branch and ran the podman fact tests: the file lands in the repo root as an untracked artifact. In production this would write a file on the client machine every time the fact runs. Please remove it.

Smaller notes:

  • PodmanPs.process still uses assert isinstance(output, list) plus # type: ignore. Now that _parse_podman_json_list exists, route PodmanPs through it too. (assert in src/ is dropped under python -O, so the helper is also the safer pattern.)
  • On your caveat about exception handling: wrapping parse failures in FactProcessError is the right call, keep it. The bare except Exception clause after except json.JSONDecodeError is redundant though; one or the other is enough.
  • Typo in the helper docstring: "parasing".
  • New fixtures should be YAML rather than JSON (project convention for new fixtures). Not blocking since the existing podman fixtures are JSON too, but worth doing.
  • The Podman version note on PodmanQuadlets (>= 5.6.0, unchecked) is fine.

Tests and lint pass on the branch, docs examples look right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

facts Issues with facts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants