Skip to content

Commit d9f4e48

Browse files
author
Matthew Fisher
committed
fix(controller): allow users to override cmd process types
1 parent e592528 commit d9f4e48

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

controller/api/models.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,13 @@ def _get_scheduler(self):
401401
_scheduler = property(_get_scheduler)
402402

403403
def _get_command(self):
404-
# handle special case for Dockerfile deployments
405-
if self.type == 'cmd':
406-
return ''
407404
try:
408405
# ensure they cannot break out and run commands on the host
409406
return "bash -c '{}'".format(self.release.build.procfile[self.type])
410407
# if the key is not present or if a parent attribute is None
411-
except (KeyError, TypeError):
412-
return 'start {}'.format(self.type)
408+
except (KeyError, TypeError, AttributeError):
409+
# handle special case for Dockerfile deployments
410+
return '' if self.type == 'cmd' else 'start {}'.format(self.type)
413411

414412
_command = property(_get_command)
415413

controller/api/tests/test_container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,15 @@ def test_command_good(self):
462462
type='web',
463463
num=1)
464464
self.assertEqual(c._command, "bash -c 'node server.js'")
465+
c.type = 'cmd'
466+
self.assertEqual(c._command, '')
467+
# ensure we can override the cmd process type in a Procfile
468+
build.procfile['cmd'] = 'node server.js'
469+
self.assertEqual(c._command, "bash -c 'node server.js'")
465470
c.type = 'worker'
466471
self.assertEqual(c._command, "bash -c 'node worker.js'")
467472
c.release.build.procfile = None
468473
self.assertEqual(c._command, 'start worker')
469-
c.type = 'cmd'
470-
self.assertEqual(c._command, '')
471474

472475
def test_run_command_good(self):
473476
"""Test the run command for each container workflow"""

0 commit comments

Comments
 (0)