diff options
author | Joffrey F <joffrey@docker.com> | 2018-01-26 14:25:00 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-01-26 14:25:11 -0800 |
commit | 601c5a41d2e6d281fa9917a0dd9b66dd45b8dcae (patch) | |
tree | 424c1d2a7448ab25882b1c1292650d6226e338a6 | |
parent | 04eb7a2a9934489bd4d7739b0ec2364e0e0ef593 (diff) | |
parent | 35ceefe1f121c8d829173cbc8f18dd5965308073 (diff) | |
download | docker-py-601c5a41d2e6d281fa9917a0dd9b66dd45b8dcae.tar.gz |
Merge branch 'image-load' of https://github.com/hongbin/docker-py into hongbin-image-load
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/models/images.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/docker/models/images.py b/docker/models/images.py index 891c565..4372730 100644 --- a/docker/models/images.py +++ b/docker/models/images.py @@ -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): """ |