Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't run the entrypoint for each line in a multi-line script #121

Merged
merged 1 commit into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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