Skip to content

Commit 601c5a4

Browse files
committed
Merge branch 'image-load' of https://github.com/hongbin/docker-py into hongbin-image-load
Signed-off-by: Joffrey F <[email protected]>
2 parents 04eb7a2 + 35ceefe commit 601c5a4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docker/models/images.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,24 @@ def load(self, data):
241241
data (binary): Image data to be loaded.
242242
243243
Returns:
244-
(generator): Progress output as JSON objects
244+
(list of :py:class:`Image`): The images.
245245
246246
Raises:
247247
:py:class:`docker.errors.APIError`
248248
If the server returns an error.
249249
"""
250-
return self.client.api.load_image(data)
250+
resp = self.client.api.load_image(data)
251+
images = []
252+
for chunk in resp:
253+
if 'stream' in chunk:
254+
match = re.search(
255+
r'(^Loaded image ID: |^Loaded image: )(.+)$',
256+
chunk['stream']
257+
)
258+
if match:
259+
image_id = match.group(2)
260+
images.append(image_id)
261+
return [self.get(i) for i in images]
251262

252263
def pull(self, name, tag=None, **kwargs):
253264
"""

0 commit comments

Comments
 (0)