Skip to content

Commit ea81cd2

Browse files
author
smothiki
committed
feat(slugrunner): make slugrunner configurable via env variables
1 parent ba6ed29 commit ea81cd2

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

rootfs/deis/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@
262262
random_secret = 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi*#@&*^'
263263
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', random_secret)
264264
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', random_secret)
265+
defaultImage = "quay.io/deisci/slugrunner:canary"
266+
SLUGRUNNER_IMAGE = os.environ.get('SLUGRUNNER_IMAGE_NAME', defaultImage)
265267

266268
# registry settings
267269
REGISTRY_HOST = os.environ.get('DEIS_REGISTRY_SERVICE_HOST', '127.0.0.1')

rootfs/scheduler/__init__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"containers": [
2929
{
3030
"name": "$id",
31-
"image": "quay.io/deisci/slugrunner:v2-beta",
31+
"image": "$slugimage",
3232
"env": [
3333
{
3434
"name":"PORT",
@@ -172,7 +172,7 @@
172172
"containers": [
173173
{
174174
"name": "$containername",
175-
"image": "quay.io/deisci/slugrunner:v2-beta",
175+
"image": "$slugimage",
176176
"imagePullPolicy": "Always",
177177
"env": [
178178
{
@@ -469,14 +469,18 @@ def run(self, name, image, entrypoint, command, **kwargs):
469469
name = name.replace('.', '-').replace('_', '-')
470470
imgurl = self.registry + '/' + image
471471
POD = POD_TEMPLATE
472-
if image.startswith('http://') or image.startswith('https://'):
473-
POD = POD_BTEMPLATE
474-
imgurl = image
472+
475473
l = {
476474
'id': name,
477475
'version': self.apiversion,
478476
'image': imgurl,
479477
}
478+
479+
if image.startswith('http://') or image.startswith('https://'):
480+
POD = POD_BTEMPLATE
481+
l["image"] = image
482+
l["slugimage"] = settings.SLUGRUNNER_IMAGE
483+
480484
template = string.Template(POD).substitute(l)
481485
if command.startswith('-c '):
482486
args = command.split(' ', 1)
@@ -846,11 +850,6 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
846850
imgurl = self.registry + "/" + image
847851
TEMPLATE = RCD_TEMPLATE
848852

849-
# Check if it is a slug builder image.
850-
if kwargs.get('build_type') == "buildpack":
851-
imgurl = image
852-
TEMPLATE = RCB_TEMPLATE
853-
854853
l = {
855854
"name": name,
856855
"id": namespace,
@@ -861,6 +860,13 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
861860
"containername": container_name,
862861
"type": app_type,
863862
}
863+
864+
# Check if it is a slug builder image.
865+
if kwargs.get('build_type') == "buildpack":
866+
l["image"] = image
867+
l["slugimage"] = settings.SLUGRUNNER_IMAGE
868+
TEMPLATE = RCB_TEMPLATE
869+
864870
template = json.loads(string.Template(TEMPLATE).substitute(l))
865871

866872
# apply tags as needed

0 commit comments

Comments
 (0)