mirror of https://github.com/docker/docker-py.git
Fix #1351
* Fix TypeError when getting the tags property from an image that has no tags. Ex: An image pulled by cryptohash. It is handled like when the image doesn't have defined the RepoTags member. Signed-off-by: Alejandro E. Brito Monedero <alejandro.monedero@gmail.com>
This commit is contained in:
parent
aed1af6f6f
commit
95b6fddd14
|
|
@ -30,10 +30,10 @@ class Image(Model):
|
|||
"""
|
||||
The image's tags.
|
||||
"""
|
||||
return [
|
||||
tag for tag in self.attrs.get('RepoTags', [])
|
||||
if tag != '<none>:<none>'
|
||||
]
|
||||
tags = self.attrs.get('RepoTags')
|
||||
if tags is None:
|
||||
tags = []
|
||||
return [tag for tag in tags if tag != '<none>:<none>']
|
||||
|
||||
def history(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ class ImageTest(unittest.TestCase):
|
|||
})
|
||||
assert image.tags == []
|
||||
|
||||
image = Image(attrs={
|
||||
'RepoTags': None
|
||||
})
|
||||
assert image.tags == []
|
||||
|
||||
def test_history(self):
|
||||
client = make_fake_client()
|
||||
image = client.images.get(FAKE_IMAGE_ID)
|
||||
|
|
|
|||
Loading…
Reference in New Issue