mirror of https://github.com/docker/compose.git
fix race condition after pulling image
Signed-off-by: Stephan Müller <mail@stephanmueller.eu>
This commit is contained in:
parent
4bd93b95a9
commit
56fbd22825
|
@ -98,14 +98,14 @@ def print_output_event(event, stream, is_terminal):
|
||||||
|
|
||||||
|
|
||||||
def get_digest_from_pull(events):
|
def get_digest_from_pull(events):
|
||||||
|
digest = None
|
||||||
for event in events:
|
for event in events:
|
||||||
status = event.get('status')
|
status = event.get('status')
|
||||||
if not status or 'Digest' not in status:
|
if not status or 'Digest' not in status:
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
_, digest = status.split(':', 1)
|
digest = status.split(':', 1)[1].strip()
|
||||||
return digest.strip()
|
return digest
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def get_digest_from_push(events):
|
def get_digest_from_push(events):
|
||||||
|
|
|
@ -97,22 +97,24 @@ class ProgressStreamTestCase(unittest.TestCase):
|
||||||
tf.seek(0)
|
tf.seek(0)
|
||||||
assert tf.read() == '???'
|
assert tf.read() == '???'
|
||||||
|
|
||||||
|
def test_get_digest_from_push(self):
|
||||||
|
digest = "sha256:abcd"
|
||||||
|
events = [
|
||||||
|
{"status": "..."},
|
||||||
|
{"status": "..."},
|
||||||
|
{"progressDetail": {}, "aux": {"Digest": digest}},
|
||||||
|
]
|
||||||
|
assert progress_stream.get_digest_from_push(events) == digest
|
||||||
|
|
||||||
def test_get_digest_from_push():
|
def test_get_digest_from_pull(self):
|
||||||
digest = "sha256:abcd"
|
events = list()
|
||||||
events = [
|
assert progress_stream.get_digest_from_pull(events) is None
|
||||||
{"status": "..."},
|
|
||||||
{"status": "..."},
|
|
||||||
{"progressDetail": {}, "aux": {"Digest": digest}},
|
|
||||||
]
|
|
||||||
assert progress_stream.get_digest_from_push(events) == digest
|
|
||||||
|
|
||||||
|
digest = "sha256:abcd"
|
||||||
def test_get_digest_from_pull():
|
events = [
|
||||||
digest = "sha256:abcd"
|
{"status": "..."},
|
||||||
events = [
|
{"status": "..."},
|
||||||
{"status": "..."},
|
{"status": "Digest: %s" % digest},
|
||||||
{"status": "..."},
|
{"status": "..."},
|
||||||
{"status": "Digest: %s" % digest},
|
]
|
||||||
]
|
assert progress_stream.get_digest_from_pull(events) == digest
|
||||||
assert progress_stream.get_digest_from_pull(events) == digest
|
|
||||||
|
|
Loading…
Reference in New Issue