Require image info in a fixed format

pull/848/head
Simon Li 2020-02-14 13:15:04 +00:00
rodzic 787d1d3aeb
commit a73595ce4c
3 zmienionych plików z 30 dodań i 8 usunięć

Wyświetl plik

@ -670,10 +670,9 @@ class Repo2Docker(Application):
# check if we already have an image for this content # check if we already have an image for this content
client = self.get_engine() client = self.get_engine()
for image in client.images(): for image in client.images():
if image["RepoTags"] is not None: for tag in image.tags:
for tag in image["RepoTags"]: if tag == self.output_image_spec + ":latest":
if tag == self.output_image_spec + ":latest": return True
return True
return False return False
def build(self): def build(self):

Wyświetl plik

@ -3,7 +3,7 @@ Docker container engine for repo2docker
""" """
import docker import docker
from .engine import Container, ContainerEngine, ContainerEngineException from .engine import Container, ContainerEngine, ContainerEngineException, Image
class DockerContainer(Container): class DockerContainer(Container):
@ -78,7 +78,8 @@ class DockerEngine(ContainerEngine):
) )
def images(self): def images(self):
return self._apiclient.images() images = self._apiclient.images()
return [Image(tags=image["RepoTags"]) for image in images]
def inspect_image(self, image): def inspect_image(self, image):
return self._apiclient.inspect_image(image) return self._apiclient.inspect_image(image)

Wyświetl plik

@ -84,9 +84,31 @@ class Container(ABC):
""" """
class Image:
"""
Information about a container image
"""
def __init__(self, *, tags):
self._tags = tags or []
@property
def tags(self):
"""
A list of tags associated with an image.
If locally built images have a localhost prefix this prefix should be removed or the image may not be recognised.
If there are no tags [] will be returned.
"""
return self._tags
def __repr__(self):
return "Image(tags={})".format(self.tags)
class ContainerEngine(ABC): class ContainerEngine(ABC):
""" """
Abstract container engine Abstract container engine.
""" """
# containers = Container # containers = Container
@ -156,7 +178,7 @@ class ContainerEngine(ABC):
Returns Returns
------- -------
list[str] : List of images list[Image] : List of Image objects.
""" """
@abstractmethod @abstractmethod