mirror of https://github.com/docker/docker-py.git
Error handling in ImageCollection.load
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
601c5a41d2
commit
8b5a52ae0c
|
@ -144,6 +144,10 @@ class BuildError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class ImageLoadError(DockerException):
|
||||
pass
|
||||
|
||||
|
||||
def create_unexpected_kwargs_error(name, kwargs):
|
||||
quoted_kwargs = ["'{}'".format(k) for k in sorted(kwargs)]
|
||||
text = ["{}() ".format(name)]
|
||||
|
|
|
@ -3,7 +3,7 @@ import re
|
|||
import six
|
||||
|
||||
from ..api import APIClient
|
||||
from ..errors import BuildError
|
||||
from ..errors import BuildError, ImageLoadError
|
||||
from ..utils.json_stream import json_stream
|
||||
from .resource import Collection, Model
|
||||
|
||||
|
@ -258,6 +258,9 @@ class ImageCollection(Collection):
|
|||
if match:
|
||||
image_id = match.group(2)
|
||||
images.append(image_id)
|
||||
if 'error' in chunk:
|
||||
raise ImageLoadError(chunk['error'])
|
||||
|
||||
return [self.get(i) for i in images]
|
||||
|
||||
def pull(self, name, tag=None, **kwargs):
|
||||
|
|
|
@ -71,6 +71,11 @@ class ImageCollectionTest(BaseIntegrationTest):
|
|||
image = client.images.pull('alpine', tag='3.3')
|
||||
assert 'alpine:3.3' in image.attrs['RepoTags']
|
||||
|
||||
def test_load_error(self):
|
||||
client = docker.from_env(version=TEST_API_VERSION)
|
||||
with pytest.raises(docker.errors.ImageLoadError):
|
||||
client.images.load('abc')
|
||||
|
||||
|
||||
class ImageTest(BaseIntegrationTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue