Make push optional and default to False

Let's optimize the defaults for good commandline usage rather
than for binderhub usage
pull/6/head
yuvipanda 2017-05-22 22:17:02 -07:00
rodzic 542c7a9a1c
commit ae124ec2f7
1 zmienionych plików z 28 dodań i 14 usunięć

Wyświetl plik

@ -92,11 +92,20 @@ class Repo2Docker(Application):
""" """
) )
push = Bool(
False,
config=True,
help="""
If the image should be pushed after it is built.
"""
)
aliases = Dict({ aliases = Dict({
'repo': 'Repo2Docker.repo', 'repo': 'Repo2Docker.repo',
'ref': 'Repo2Docker.ref', 'ref': 'Repo2Docker.ref',
'image': 'Repo2Docker.output_image_spec', 'image': 'Repo2Docker.output_image_spec',
'clean': 'Repo2Docker.cleanup_checkout', 'clean': 'Repo2Docker.cleanup_checkout',
'push': 'Repo2Docker.push',
'f': 'Repo2Docker.config_file', 'f': 'Repo2Docker.config_file',
}) })
@ -174,11 +183,15 @@ class Repo2Docker(Application):
self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed')) self.log.error('Could not figure out how to build this repository! Tell us?', extra=dict(phase='failed'))
sys.exit(1) sys.exit(1)
if self.push:
# Build a progress setup for each layer, and only emit per-layer info every 1.5s # Build a progress setup for each layer, and only emit per-layer info every 1.5s
layers = {} layers = {}
last_emit_time = time.time() last_emit_time = time.time()
for line in client.push(self.output_image_spec, stream=True): for line in client.push(self.output_image_spec, stream=True):
progress = json.loads(line.decode('utf-8')) progress = json.loads(line.decode('utf-8'))
if 'error' in progress:
self.log.error(progress['error'], extra=dict(phase='failed'))
sys.exit(1)
if 'id' not in progress: if 'id' not in progress:
continue continue
if 'progressDetail' in progress and progress['progressDetail']: if 'progressDetail' in progress and progress['progressDetail']:
@ -189,6 +202,7 @@ class Repo2Docker(Application):
self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing')) self.log.info('Pushing image', extra=dict(progress=layers, phase='pushing'))
last_emit_time = time.time() last_emit_time = time.time()
if self.cleanup_checkout: if self.cleanup_checkout:
shutil.rmtree(checkout_path) shutil.rmtree(checkout_path)