summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2015-05-29 17:32:18 +0100
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2015-05-29 17:32:18 +0100
commit56c7db5201f548aff7950e778ca0e106709623ae (patch)
treec09551baf5b861caeb2e6e0f5005ec425d67985a
parent7929082eac2d9dc90b276afae6c201f47177c48b (diff)
downloadmorph-56c7db5201f548aff7950e778ca0e106709623ae.tar.gz
Do not call str() on None types in sanitize_env
For a cluster morph, - morph: systems/devel-system-x86_64-generic.morph deploy: self: type: ssh-rsync location: root@127.0.0.1 ATTACK_KITTENS: The yaml parser will assign the value None to the element with key 'ATTACK_KITTENS', sanitize_environment blindly calls str() on each value in the dictionary, the result is that our extensions receive an 'ATTACK_KITTENS' environment variable with the string value 'None', this is not useful and confuses anyone trying to do basic validation in their extension. This patch makes it so that any None types are replaced with the empty string, which seems a more sensible value for this case. Change-Id: I734d33e9304f0b7d4d590e464e350d2e5b4720d3
-rw-r--r--morphlib/util.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index 9668bac5..b533dd15 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -498,7 +498,7 @@ def get_host_architecture(): # pragma: no cover
def sanitize_environment(env):
for k in env:
- env[k] = str(env[k])
+ env[k] = '' if env[k] is None else str(env[k])
def iter_trickle(iterable, limit):
'''Split an iterable up into `limit` length chunks.'''