mirror of https://github.com/docker/docker-py.git
fix #1625 where ImageCollection.build() could return early with incorrect image_id depending on docer build output Signed-off-by: Chris Ottinger <chris.ottinger@team.telstra.com>
This commit is contained in:
parent
dc2b24dcdd
commit
45aec93089
|
@ -169,19 +169,20 @@ class ImageCollection(Collection):
|
||||||
if isinstance(resp, six.string_types):
|
if isinstance(resp, six.string_types):
|
||||||
return self.get(resp)
|
return self.get(resp)
|
||||||
last_event = None
|
last_event = None
|
||||||
|
image_id = None
|
||||||
for chunk in json_stream(resp):
|
for chunk in json_stream(resp):
|
||||||
if 'error' in chunk:
|
if 'error' in chunk:
|
||||||
raise BuildError(chunk['error'])
|
raise BuildError(chunk['error'])
|
||||||
if 'stream' in chunk:
|
if 'stream' in chunk:
|
||||||
match = re.search(
|
match = re.search(
|
||||||
r'(Successfully built |sha256:)([0-9a-f]+)',
|
r'(^Successfully built |sha256:)([0-9a-f]+)$',
|
||||||
chunk['stream']
|
chunk['stream']
|
||||||
)
|
)
|
||||||
if match:
|
if match:
|
||||||
image_id = match.group(2)
|
image_id = match.group(2)
|
||||||
return self.get(image_id)
|
|
||||||
last_event = chunk
|
last_event = chunk
|
||||||
|
if image_id:
|
||||||
|
return self.get(image_id)
|
||||||
raise BuildError(last_event or 'Unknown')
|
raise BuildError(last_event or 'Unknown')
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
|
|
Loading…
Reference in New Issue