From a56e59abc152d43b3e946aff7d3c17f18678af37 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 15 Jun 2018 16:24:51 +0200 Subject: [PATCH 1/2] Allow `.` in variables used for interpolation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > Environment variable names used by the utilities in the Shell and > Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase > letters, digits, and the '_' (underscore) from the characters > defined in Portable Character Set and do not begin with a > digit. **Other characters may be permitted by an implementation; > applications shall tolerate the presence of such names**. Uppercase > and lowercase letters shall retain their unique identities and shall > not be folded together. The name space of environment variable names > containing lowercase letters is reserved for applications. As it is possible to use them in environment variable, we should also allow them during interpolation. It's also required if we want to allow smarter interpolation in the future (and for `docker/app` too 👼) Signed-off-by: Vincent Demeester --- cli/compose/template/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/compose/template/template.go b/cli/compose/template/template.go index 086194b8fe84..d59bdb41e7e0 100644 --- a/cli/compose/template/template.go +++ b/cli/compose/template/template.go @@ -7,7 +7,7 @@ import ( ) var delimiter = "\\$" -var substitution = "[_a-z][_a-z0-9]*(?::?[-?][^}]*)?" +var substitution = "[_a-z.][_a-z0-9.]*(?::?[-?][^}]*)?" var patternString = fmt.Sprintf( "%s(?i:(?P%s)|(?P%s)|{(?P%s)}|(?P))", From 318812e13d56e3438ad1e6c56010c76a46502efc Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Fri, 15 Jun 2018 16:25:18 +0200 Subject: [PATCH 2/2] template.go: Group var together Signed-off-by: Vincent Demeester --- cli/compose/template/template.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/compose/template/template.go b/cli/compose/template/template.go index d59bdb41e7e0..bc1ca2ffb6fa 100644 --- a/cli/compose/template/template.go +++ b/cli/compose/template/template.go @@ -6,15 +6,17 @@ import ( "strings" ) -var delimiter = "\\$" -var substitution = "[_a-z.][_a-z0-9.]*(?::?[-?][^}]*)?" +var ( + delimiter = "\\$" + substitution = "[_a-z.][_a-z0-9.]*(?::?[-?][^}]*)?" -var patternString = fmt.Sprintf( - "%s(?i:(?P%s)|(?P%s)|{(?P%s)}|(?P))", - delimiter, delimiter, substitution, substitution, -) + patternString = fmt.Sprintf( + "%s(?i:(?P%s)|(?P%s)|{(?P%s)}|(?P))", + delimiter, delimiter, substitution, substitution, + ) -var pattern = regexp.MustCompile(patternString) + pattern = regexp.MustCompile(patternString) +) // InvalidTemplateError is returned when a variable template is not in a valid // format