Browse Source

Support non-alphanumeric default values.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 9 years ago
parent
commit
2bce81508e
2 changed files with 2 additions and 1 deletions
  1. 1 1
      compose/config/interpolation.py
  2. 1 0
      tests/unit/config/interpolation_test.py

+ 1 - 1
compose/config/interpolation.py

@@ -72,7 +72,7 @@ def recursive_interpolate(obj, interpolator):
 
 
 class TemplateWithDefaults(Template):
-    idpattern = r'[_a-z][_a-z0-9]*(?::?-[_a-z0-9]+)?'
+    idpattern = r'[_a-z][_a-z0-9]*(?::?-[^}]+)?'
 
     # Modified from python2.7/string.py
     def substitute(self, mapping):

+ 1 - 0
tests/unit/config/interpolation_test.py

@@ -113,6 +113,7 @@ def test_interpolate_with_value(defaults_interpolator):
 def test_interpolate_missing_with_default(defaults_interpolator):
     assert defaults_interpolator("ok ${missing:-def}") == "ok def"
     assert defaults_interpolator("ok ${missing-def}") == "ok def"
+    assert defaults_interpolator("ok ${BAR:-/non:-alphanumeric}") == "ok /non:-alphanumeric"
 
 
 def test_interpolate_with_empty_and_default_value(defaults_interpolator):