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

DockerImages fact raises exception when there are no images present #1278

Open
robertmx opened this issue Jan 20, 2025 · 0 comments
Open

DockerImages fact raises exception when there are no images present #1278

robertmx opened this issue Jan 20, 2025 · 0 comments

Comments

@robertmx
Copy link

robertmx commented Jan 20, 2025

Describe the bug

The pyinfra.facts.docker.DockerImages fact raises an exception if there is no image.

To Reproduce

  1. Ensure there are no images present with docker image ls
  2. Check the fact with host.get_fact(DockerImages)
  3. Exception "docker image inspect requires at least on argument"

Expected behavior

I expect it to return an empty list instead of an exception

Meta

Pyinfra 3.2

The behavior is rather obvious when looking at the implementation of DockerImages. In case of no images, docker inspect runs with no arguments. Maybe it would be prudent to check for at least one image?

class DockerImages(DockerFactBase):
    """
    Returns ``docker inspect`` output for all Docker images.
    """

    def command(self) -> str:
        return "docker image inspect `docker images -q`"
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

No branches or pull requests

1 participant