Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

fix(api): split command arguments by space if entrypoint is not /bin/bash -c #1264

Merged
merged 1 commit into from
Mar 15, 2017
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
8 changes: 7 additions & 1 deletion rootfs/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ def _get_command(self, container_type):
# FIXME: remove slugrunner's hardcoded entrypoint
release = self.release_set.filter(failed=False).latest()
if release.build.dockerfile or not release.build.sha:
return [release.build.procfile[container_type]]
cmd = release.build.procfile[container_type]
# if the entrypoint is `/bin/bash -c`, we want to supply the list
# as a script. Otherwise, we want to send it as a list of arguments.
if self._get_entrypoint(container_type) == ['/bin/bash', '-c']:
return [cmd]
else:
return cmd.split()

return ['start', container_type]
# if the key is not present or if a parent attribute is None
Expand Down
4 changes: 3 additions & 1 deletion rootfs/api/tests/test_pods.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,9 @@ def test_command_good(self, mock_requests):
# ensure we can override the cmd process type in a Procfile
build.procfile['cmd'] = 'node server.js'
build.save()
self.assertEqual(app._get_command('cmd'), ["node server.js"])
self.assertEqual(app._get_entrypoint('cmd'), [])
self.assertEqual(app._get_command('cmd'), ["node", "server.js"])
self.assertEqual(app._get_entrypoint('worker'), ["/bin/bash", "-c"])
self.assertEqual(app._get_command('worker'), ["node worker.js"])

# for backwards compatibility if no Procfile is supplied
Expand Down