Skip to content

Commit d43f5e7

Browse files
author
Matthew Fisher
committed
Merge pull request #2669 from bacongobbler/allow-cmd-override
fix(controller): allow users to override `cmd` process types
2 parents a5d1aaa + d9f4e48 commit d43f5e7

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
@@ -403,9 +403,6 @@ def _get_scheduler(self):
403403
_scheduler = property(_get_scheduler)
404404

405405
def _get_command(self):
406-
# handle special case for Dockerfile deployments
407-
if self.type == 'cmd':
408-
return ''
409406
try:
410407
# if this is not procfile-based app, ensure they cannot break out
411408
# and run arbitrary commands on the host
@@ -415,8 +412,9 @@ def _get_command(self):
415412
else:
416413
return 'start {}'.format(self.type)
417414
# if the key is not present or if a parent attribute is None
418-
except (KeyError, TypeError):
419-
return 'start {}'.format(self.type)
415+
except (KeyError, TypeError, AttributeError):
416+
# handle special case for Dockerfile deployments
417+
return '' if self.type == 'cmd' else 'start {}'.format(self.type)
420418

421419
_command = property(_get_command)
422420

controller/api/tests/test_container.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,16 @@ def test_command_good(self):
488488
build.sha = 'european-swallow'
489489
build.dockerfile = 'dockerdockerdocker'
490490
self.assertEqual(c._command, "bash -c 'node server.js'")
491+
c.type = 'cmd'
492+
self.assertEqual(c._command, '')
493+
# ensure we can override the cmd process type in a Procfile
494+
build.procfile['cmd'] = 'node server.js'
495+
self.assertEqual(c._command, "bash -c 'node server.js'")
491496
c.type = 'worker'
492497
self.assertEqual(c._command, "bash -c 'node worker.js'")
493498
c.release.build.procfile = None
494499
# for backwards compatibility if no Procfile is supplied
495500
self.assertEqual(c._command, 'start worker')
496-
c.type = 'cmd'
497-
self.assertEqual(c._command, '')
498501

499502
def test_run_command_good(self):
500503
"""Test the run command for each container workflow"""

0 commit comments

Comments
 (0)