Merge branch 'image-load' of https://github.com/hongbin/docker-py into hongbin-image-load

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-01-26 14:25:00 -08:00
commit 601c5a41d2
1 changed files with 13 additions and 2 deletions

View File

@ -241,13 +241,24 @@ class ImageCollection(Collection):
data (binary): Image data to be loaded.
Returns:
(generator): Progress output as JSON objects
(list of :py:class:`Image`): The images.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return self.client.api.load_image(data)
resp = self.client.api.load_image(data)
images = []
for chunk in resp:
if 'stream' in chunk:
match = re.search(
r'(^Loaded image ID: |^Loaded image: )(.+)$',
chunk['stream']
)
if match:
image_id = match.group(2)
images.append(image_id)
return [self.get(i) for i in images]
def pull(self, name, tag=None, **kwargs):
"""