Skip to content

Commit 0a86112

Browse files
author
Matthew Fisher
committed
Merge pull request #2127 from bacongobbler/2100_env_in_dockerfile
fix(controller): inject config on top of existing environment
2 parents 5d6f00a + bb352b4 commit 0a86112

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

controller/api/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,8 @@ def new(self, user, config=None, build=None, summary=None, source_version='lates
618618
if not build:
619619
build = self.build
620620
# always create a release off the latest image
621-
source_image = '{}:{}'.format(build.image, source_version)
621+
source_tag = 'git-{}'.format(build.sha) if build.sha else source_version
622+
source_image = '{}:{}'.format(build.image, source_tag)
622623
# construct fully-qualified target image
623624
new_version = self.version + 1
624625
tag = 'v{}'.format(new_version)

controller/registry/private.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def publish_release(source, config, target):
5959
image['id'] = _new_id()
6060
config['DEIS_APP'] = target_image
6161
config['DEIS_RELEASE'] = target_tag
62-
image['config']['Env'] = _construct_env(config)
62+
image['config']['Env'] = _construct_env(image['config']['Env'], config)
6363
# update and tag the new image
6464
_commit(target_image, image, _empty_tar_archive(), target_tag)
6565

@@ -72,8 +72,6 @@ def _commit(repository_path, image, layer, tag):
7272
cookies = _put_layer(image['id'], layer)
7373
_put_checksum(image, cookies)
7474
_put_tag(image['id'], repository_path, tag)
75-
# point latest to the new tag
76-
_put_tag(image['id'], repository_path, 'latest')
7775

7876

7977
def _put_first_image(repository_path):
@@ -162,10 +160,17 @@ def _put_tag(image_id, repository_path, tag):
162160

163161
# utility functions
164162

165-
def _construct_env(config):
163+
def _construct_env(env, config):
166164
"Update current environment with latest config"
167165
new_env = []
168-
# add config ENV items
166+
# see if we need to update existing ENV vars
167+
for e in env:
168+
k, v = e.split('=', 1)
169+
if k in config:
170+
# update values defined by config
171+
v = config.pop(k)
172+
new_env.append("{}={}".format(encode(k), encode(v)))
173+
# add other config ENV items
169174
for k, v in config.items():
170175
new_env.append("{}={}".format(encode(k), encode(v)))
171176
return new_env

0 commit comments

Comments
 (0)