Repository navigation
Conversation
Extract _docker_cmd() and _docker_inspect_all() helpers to deduplicate identical docker_cmd extraction and inspect-all command templates across Docker facts. DockerSystemInfo.command() now respects docker_cmd like requires_command() already did.
Complete the unfinished PodmanFactBase docstring fragment and update PodmanSystemInfo/PodmanPs to match the Docker Returns ... docstring convention.
Add docker_cmd: str = "docker" parameter to all 10 docker operations (container, image, build, volume, network, prune, plugin, login, logout, compose). Each operation passes docker_cmd through to generated commands and host.get_fact() calls so podman can replace docker. build_cmd now derives from docker_cmd when not explicitly provided.
…ngCommand args
Replace f"{docker_cmd} ..." single-string prefixes with explicit
StringCommand(docker_cmd, "subcommand", ...) arguments in all 16 command
builders. No behavior change, generated commands are identical.
Add pyinfra.operations.podman proxy module wrapping all 10 docker operations. Each proxy sets docker_cmd="podman" (or compose_command="podman compose" for compose) and delegates via docker.<op>._inner(...). Register podman-ops plugin in metadata.
Add docker_cmd="podman" fixtures for login/logout/build operations, update 63 existing Docker operation fixtures to include docker_cmd=docker in fact keys, and add 10 podman proxy operation fixture directories plus DockerSystemInfo fact fixtures (default + podman).
Resolve conflicts in facts/podman.py (took upstream version with _parse_podman_json helper and new podman facts), operations/docker.py (volume gets both options and docker_cmd params), and operations/util docker.py (_create_volume gets both options and docker_cmd).
wowi42
left a comment
There was a problem hiding this comment.
This needs a split and another pass before merge. The docker_cmd change and new Podman API are separate features. I found injection and compatibility blockers inline.
Also, container_exec is missing both docker_cmd and a Podman proxy, most changed fact commands lack custom-command fixtures, and the root mr-description.md artifact should be removed.
| return kwargs.get("docker_cmd") or "docker" | ||
|
|
||
|
|
||
| def _docker_inspect_all(docker_cmd: str, resource: str, list_command: str) -> str: |
There was a problem hiding this comment.
The new docker_cmd value is interpolated directly into shell text here and in operation commands. A value with shell metacharacters can execute injected syntax. Please quote the executable with QuoteString and add hostile-input fixtures.
| yield from docker.prune._inner(*args, **kwargs) | ||
|
|
||
|
|
||
| @operation() |
There was a problem hiding this comment.
Podman has no plugin command. The network proxy can also pass --scope, --ingress, --attachable, and --aux-address, which podman network create does not support. Please remove or gate unsupported commands and flags and test against the real CLI.
| @@ -759,7 +800,7 @@ def login( | |||
| command_bits: list = [ | |||
There was a problem hiding this comment.
The auth fact only reads Docker's config, even when docker_cmd is Podman. Podman login normally writes ${XDG_RUNTIME_DIR}/containers/auth.json, so login/logout idempotency will be wrong. Please use command-aware auth state and cover the Podman path.
| yield from docker.network._inner(*args, **kwargs) | ||
|
|
||
|
|
||
| @operation() |
There was a problem hiding this comment.
The proxy functions expose only *args and **kwargs, so their public signatures and parameter docs are lost. prune and compose also lose the target operations' non-idempotent decorator setting. Please preserve the wrapped API and metadata.
Format the QuoteString(docker_cmd) wrapping introduced by ruff format and remove the mr-description.md artifact requested by the reviewer.
|
Resolved ✅ — @wowi42
A hostile value like Added hostile-input fixtures:
Fixes committed and pushed to |
|
Resolved ✅ — @wowi42
Remaining proxies route through |
|
Resolved ✅ — @wowi42
|
|
Resolved ✅ — @wowi42 The proxies now declare explicit parameter signatures matching the wrapped docker operations, with full docstrings. Each delegates via
Summary of remaining review points:
|
Summary
Allow Docker-compatible CLI (e.g. Podman) to replace Docker via a
docker_cmdparameter on all Docker operations, plus a newpyinfra.operations.podmanproxy module that routes every command throughpodmaninstead ofdocker.Changes
pyinfra/operations/docker.py (commit 9fffb56)
docker_cmd: str = "docker"parameter to all 10 operations:container,image,build,volume,network,prune,plugin,login,logout,composebuild_cmdnow derives fromdocker_cmdwhen not explicitly provided (f"{docker_cmd} build")composekeepscompose_command: str = "docker compose"(unchanged — already switchable)docker_cmdthrough to generatedStringCommands andhost.get_fact(...)callsdocker_cmdparameters documented in operation docstrings (+ docker_cmd: Docker-compatible CLI to substitute for ``docker`` (e.g. ``podman``))logindocstring: removed hardcodeddocker loginreference in proseDockerSystemInfo.command()now respectsdocker_cmdlikerequires_command()already didpyinfra/operations/util/docker.py (commit bf67c22)
_create_container,_remove_container,_start_container,_stop_container,_pull_image,_remove_image,_prune_command,_create_volume,_remove_volume,_create_network,_remove_network,_install_plugin,_remove_plugin,_enable_plugin,_disable_plugin,_set_plugin_options) acceptdocker_cmdas an explicitStringCommandargument instead of anf"{docker_cmd} ..."prefixpyinfra/operations/podman.py (commit 5cd2450, new)
kwargs["docker_cmd"] = "podman"(orcompose_command="podman compose"forcompose) and delegates viadocker.<op>._inner(...)pyinfra/facts/docker.py (commit 580735d)
_docker_cmd(kwargs)helper — replaced 10 identicalkwargs.get("docker_cmd") or "docker"extractions (3requires_command+ 7commandsites)_docker_inspect_all(docker_cmd, resource, list_command)helper — replaced 3 identical inspect-all command templates (containersps -qa, imagesimages -q, pluginsplugin ls -q)DockerSystemInfo.command()now respectsdocker_cmdpyinfra/facts/podman.py (commit 8a7fe13)
PodmanFactBasedocstring (was an unfinished fragment)PodmanSystemInfoandPodmanPsdocstrings to match the DockerReturns ...conventionpyinfra-metadata.toml (commit 5cd2450)
podman-opsplugin (name="podman",path="src/pyinfra/operations/podman.py",type="operation",tags=["containers"])Tests (commit 9a3307b)
docker_cmd="podman"fixtures forlogin/logout(4 fixtures)docker_cmd="podman"fixture forbuild(build_with_docker_cmd.json)podman.container,podman.image,podman.build,podman.volume,podman.network,podman.plugin,podman.login,podman.logout,podman.prune,podman.compose)DockerSystemInfofact fixtures (default +docker_cmd=podman)docker_cmd=dockerin fact keysDocumentation
docs/operations/docker.mdanddocs/operations/podman.mdviascripts/generate_operations_docs.pyCommit organization
7 atomic commits (in order):
docker_cmdhelperskwargs.get("docker_cmd") or "docker"extractions + 3 inspect-all templates;DockerSystemInfo.command()now respectsdocker_cmdPodmanFactBasefragment; updatePodmanSystemInfo/PodmanPsdocker_cmdparameterdocker_cmdthrough all 10 docker operationsStringCommandargsStringCommand(docker_cmd, "subcommand", ...)podmanproxy operationsoperations/podman.py+podman-opsmetadata plugindocker_cmdand podman fixtures3.xin facts/podman.py, operations/docker.py, operations/util/docker.pyVerification
uv run pytest tests/test_operations.py tests/test_facts.py→ 1428 passeduv run ruff check→ pass (only pre-existing E402 ondocker.py:22from base commit)uv run ruff format --check→ passuv run mypy→ passChecklist
3.xat this time)scripts/dev-test.sh)scripts/dev-lint.sh)feat(operations.docker): allow podman to replace docker via docker_cmd)operations.docker)Notes for reviewers
DockerAuthsfact intentionally does not acceptdocker_cmd— it reads${DOCKER_CONFIG:-$HOME/.docker}/config.jsondirectly, which is shared between docker and podman (both honorDOCKER_CONFIGand default to~/.docker/config.json).composekeeps its owncompose_command: str = "docker compose"default (with space) sincedocker compose/podman composeis a subcommand invocation, not a bare binary name.login/logouthardcode neitherdockernorpodmanin generated commands;docker_cmdcontrols the binary. Prose in thelogindocstring no longer saysdocker login.facts/podman.py) remain standalone; they do not proxy to Docker facts because the fact framework lacks the_innerescape hatch that operations use.