kopia lustrzana https://github.com/jupyterhub/repo2docker
Require image info in a fixed format
rodzic
787d1d3aeb
commit
a73595ce4c
|
@ -670,10 +670,9 @@ class Repo2Docker(Application):
|
|||
# check if we already have an image for this content
|
||||
client = self.get_engine()
|
||||
for image in client.images():
|
||||
if image["RepoTags"] is not None:
|
||||
for tag in image["RepoTags"]:
|
||||
if tag == self.output_image_spec + ":latest":
|
||||
return True
|
||||
for tag in image.tags:
|
||||
if tag == self.output_image_spec + ":latest":
|
||||
return True
|
||||
return False
|
||||
|
||||
def build(self):
|
||||
|
|
|
@ -3,7 +3,7 @@ Docker container engine for repo2docker
|
|||
"""
|
||||
|
||||
import docker
|
||||
from .engine import Container, ContainerEngine, ContainerEngineException
|
||||
from .engine import Container, ContainerEngine, ContainerEngineException, Image
|
||||
|
||||
|
||||
class DockerContainer(Container):
|
||||
|
@ -78,7 +78,8 @@ class DockerEngine(ContainerEngine):
|
|||
)
|
||||
|
||||
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):
|
||||
return self._apiclient.inspect_image(image)
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
Abstract container engine
|
||||
Abstract container engine.
|
||||
"""
|
||||
|
||||
# containers = Container
|
||||
|
@ -156,7 +178,7 @@ class ContainerEngine(ABC):
|
|||
|
||||
Returns
|
||||
-------
|
||||
list[str] : List of images
|
||||
list[Image] : List of Image objects.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
|
|
Ładowanie…
Reference in New Issue