Skip to content

Commit c415b27

Browse files
author
Matthew Fisher
committed
fix(controller): build image from source_tag
'sha' is just metadata. it is not used as a tag on the registry. The release ledger is append-only, which means that the latest image should be used by default, with an optional source tag for rollbacks.
1 parent 01c4b0b commit c415b27

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

controller/api/models.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class Meta:
462462
def __str__(self):
463463
return "{0}-v{1}".format(self.app.id, self.version)
464464

465-
def new(self, user, config=None, build=None, summary=None):
465+
def new(self, user, config=None, build=None, summary=None, source_version='latest'):
466466
"""
467467
Create a new application release using the provided Build and Config
468468
on behalf of a user.
@@ -473,11 +473,8 @@ def new(self, user, config=None, build=None, summary=None):
473473
config = self.config
474474
if not build:
475475
build = self.build
476-
# construct fully-qualified build image
477-
if build.sha:
478-
source_image = '{}:{}'.format(build.image, build.sha)
479-
else:
480-
source_image = '{}:{}'.format(build.image, 'latest')
476+
# always create a release off the latest image
477+
source_image = '{}:{}'.format(build.image, source_version)
481478
# construct fully-qualified target image
482479
new_version = self.version + 1
483480
tag = 'v{}'.format(new_version)

controller/api/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ def rollback(self, request, *args, **kwargs):
427427
request.user,
428428
build=prev.build,
429429
config=prev.config,
430-
summary=summary)
430+
summary=summary,
431+
source_version='v{}'.format(version))
431432
app.deploy(new_release)
432433
response = {'version': new_release.version}
433434
return Response(response, status=status.HTTP_201_CREATED)

0 commit comments

Comments
 (0)