Skip to content

Commit

Permalink
scuba: Don't run the entrypoint for each line in a multi-line script
Browse files Browse the repository at this point in the history
This is a breaking change.

Fixes #114
  • Loading branch information
JonathonReinhart committed Sep 14, 2018
1 parent b1afc42 commit a0f1964
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 4 additions & 6 deletions scuba/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,18 @@ def __setup_native_run(self):
verbose_msg('{} Cmd: "{}"'.format(context.image, default_cmd))
context.script = [shell_quote_cmd(default_cmd)]

# Make scubainit the entrypoint, and manually insert an existing
# entrypoint before each user command
entrypoint = get_image_entrypoint(context.image) or []
# Make scubainit the real entrypoint, and use the defined entrypoint as
# the docker command (if it exists)
self.docker_cmd = get_image_entrypoint(context.image) or []
self.add_option('--entrypoint={}'.format(scubainit_cpath))

# The user command is executed via a generated shell script
with self.open_scubadir_file('command.sh', 'wt') as f:
self.docker_cmd = ['/bin/sh', f.container_path]
self.docker_cmd += ['/bin/sh', f.container_path]
writeln(f, '#!/bin/sh')
writeln(f, '# Auto-generated from scuba')
writeln(f, 'set -e')
for cmd in context.script:
if entrypoint:
cmd = shell_quote_cmd(entrypoint) + ' ' + cmd
writeln(f, cmd)

self.context = context
Expand Down
16 changes: 16 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,22 @@ def test_image_entrypoint(self):
assert_str_equalish('success', out)


def test_image_entrypoint_multiline(self):
'''Verify entrypoints are handled correctly with multi-line scripts'''
with open('.scuba.yml', 'w') as f:
f.write('''
image: scuba/entrypoint-test
aliases:
testalias:
script:
- cat entrypoint_works.txt
- echo $ENTRYPOINT_WORKS
''')

out, _ = self.run_scuba(['testalias'])
assert_str_equalish('\n'.join(['success']*2), out)


def test_image_override(self):
'''Verify --image works'''

Expand Down

0 comments on commit a0f1964

Please sign in to comment.