Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a typo with the volumes parameter to docker.prune operation. #1269

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

mpilone
Copy link

@mpilone mpilone commented Jan 14, 2025

Fixes a typo in the docker.prune operation that caused pyinfra to fail. Before the fix, the operation

docker.prune(
    name="Prune images",
    all=True
)

would fail with the trace

Traceback (most recent call last):
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra_cli/util.py", line 65, in exec_file
    exec(PYTHON_CODES[filename], data)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "deploy.py", line 11, in <module>
    docker.prune(
    ~~~~~~~~~~~~^
        name="Prune images",
        ^^^^^^^^^^^^^^^^^^^^
        all=True
        ^^^^^^^^
    )
    ^
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra/api/operation.py", line 295, in decorated_func
    for _ in command_generator():
             ~~~~~~~~~~~~~~~~~^^
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra/api/operation.py", line 282, in command_generator
    for command in func(*args, **kwargs):
                   ~~~~^^^^^^^^^^^^^^^^^
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra/operations/docker.py", line 334, in prune
    yield handle_docker(
          ~~~~~~~~~~~~~^
        resource="system",
        ^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        filter=filter,
        ^^^^^^^^^^^^^^
    )
    ^
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra/operations/util/docker.py", line 177, in handle_docker
    return docker_commands[resource][command](**kwargs)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/mpilone/.local/pipx/venvs/pyinfra/lib/python3.13/site-packages/pyinfra/operations/util/docker.py", line 69, in _prune_command
    if kwargs["volumes"]:
       ~~~~~~^^^^^^^^^^^
KeyError: 'volumes'

The issue was a typo where volume was used as the default argument but volumes was used later in the implementation and the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant