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

Commit

Permalink
feat(api): Allow using an unreleased image for the run command.
Browse files Browse the repository at this point in the history
This is useful for build steps which must be completed before an app is fully
deployed to deis, for example asset compilation.
  • Loading branch information
Rob Holland committed Jan 19, 2017
1 parent 145ee50 commit 6927339
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions rootfs/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion rootfs/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6927339

Please sign in to comment.