diff --git a/rootfs/api/models/app.py b/rootfs/api/models/app.py index 9143d97f1..9f7fcdd8e 100644 --- a/rootfs/api/models/app.py +++ b/rootfs/api/models/app.py @@ -684,7 +684,7 @@ def logs(self, log_lines=str(settings.LOG_LINES)): # cast content to string since it comes as bytes via the requests object return str(r.content.decode('utf-8')) - def run(self, user, command): + def run(self, user, command, image=None): def pod_name(size=5, chars=string.ascii_lowercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) @@ -695,7 +695,8 @@ def pod_name(size=5, chars=string.ascii_lowercase + string.digits): app_settings = self.appsettings_set.latest() # use slugrunner image for app if buildpack app otherwise use normal image - image = settings.SLUGRUNNER_IMAGE if release.build.type == 'buildpack' else release.image + if image is None: + image = settings.SLUGRUNNER_IMAGE if release.build.type == 'buildpack' else release.image data = self._gather_app_settings(release, app_settings, process_type='run', replicas=1) diff --git a/rootfs/api/views.py b/rootfs/api/views.py index 86c6624db..6cea82b3d 100644 --- a/rootfs/api/views.py +++ b/rootfs/api/views.py @@ -238,7 +238,7 @@ def run(self, request, **kwargs): app = self.get_object() if not request.data.get('command'): raise DeisException("command is a required field") - rc, output = app.run(self.request.user, request.data['command']) + rc, output = app.run(self.request.user, request.data['command'], image=request.data.get('image')) return Response({'exit_code': rc, 'output': str(output)}) def update(self, request, **kwargs):