From 2bce81508effe82c0bca3603769bdd2cc1b8d00f Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 6 Oct 2016 17:04:19 -0400 Subject: [PATCH] Support non-alphanumeric default values. Signed-off-by: Daniel Nephin --- compose/config/interpolation.py | 2 +- tests/unit/config/interpolation_test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compose/config/interpolation.py b/compose/config/interpolation.py index cb841437c..1b270b9ea 100644 --- a/compose/config/interpolation.py +++ b/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): diff --git a/tests/unit/config/interpolation_test.py b/tests/unit/config/interpolation_test.py index 224444950..fd40153d2 100644 --- a/tests/unit/config/interpolation_test.py +++ b/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):