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

Commit a8002a2

Browse files
author
Matthew Fisher
authored
fix(api): split command arguments by space if entrypoint is not /bin/bash -c (#1264)
1 parent 1156475 commit a8002a2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

rootfs/api/models/app.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,13 @@ def _get_command(self, container_type):
123123
# FIXME: remove slugrunner's hardcoded entrypoint
124124
release = self.release_set.filter(failed=False).latest()
125125
if release.build.dockerfile or not release.build.sha:
126-
return [release.build.procfile[container_type]]
126+
cmd = release.build.procfile[container_type]
127+
# if the entrypoint is `/bin/bash -c`, we want to supply the list
128+
# as a script. Otherwise, we want to send it as a list of arguments.
129+
if self._get_entrypoint(container_type) == ['/bin/bash', '-c']:
130+
return [cmd]
131+
else:
132+
return cmd.split()
127133

128134
return ['start', container_type]
129135
# if the key is not present or if a parent attribute is None

rootfs/api/tests/test_pods.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ def test_command_good(self, mock_requests):
512512
# ensure we can override the cmd process type in a Procfile
513513
build.procfile['cmd'] = 'node server.js'
514514
build.save()
515-
self.assertEqual(app._get_command('cmd'), ["node server.js"])
515+
self.assertEqual(app._get_entrypoint('cmd'), [])
516+
self.assertEqual(app._get_command('cmd'), ["node", "server.js"])
517+
self.assertEqual(app._get_entrypoint('worker'), ["/bin/bash", "-c"])
516518
self.assertEqual(app._get_command('worker'), ["node worker.js"])
517519

518520
# for backwards compatibility if no Procfile is supplied

0 commit comments

Comments
 (0)