Skip to content

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

Open
@robertmx

Description

@robertmx

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`"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions