Skip to content

Commit ab5f680

Browse files
committed
fix(scheduler): update instead of appending env vars so hardcoded values can be overwritten
An example of this would be a user wanting to overwrite a hardcoded PORT or one of the other values Deis may set. Generally people should not do that, however the flexibility should be there in case they want to play with fire Fixes #766
1 parent f5e43f9 commit ab5f680

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

rootfs/scheduler/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def _set_container(self, namespace, data, **kwargs): # noqa
664664
self._create_secret(namespace, secret_name, secrets_env, labels=labels)
665665

666666
for key in env.keys():
667-
data["env"].append({
667+
item = {
668668
"name": key,
669669
"valueFrom": {
670670
"secretKeyRef": {
@@ -673,7 +673,14 @@ def _set_container(self, namespace, data, **kwargs): # noqa
673673
"key": key.lower().replace('_', '-')
674674
}
675675
}
676-
})
676+
}
677+
678+
# add value to env hash. Overwrite hardcoded values if need be
679+
match = next((k for k, e in enumerate(data["env"]) if e['name'] == key), None)
680+
if match is not None:
681+
data["env"][match] = item
682+
else:
683+
data["env"].append(item)
677684

678685
# Inject debugging if workflow is in debug mode
679686
if os.environ.get("DEIS_DEBUG", False):

0 commit comments

Comments
 (0)