Skip to content

Commit 32b078a

Browse files
authored
Merge pull request #405 from ndeloof/fix_nested_var_expansion
2 parents 0dd3a5b + ed21563 commit 32b078a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

interpolation/interpolation_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func TestValidUnexistentInterpolation(t *testing.T) {
119119
{test: "{{{ ${BAR} }}}", expected: "{{{ }}}"},
120120
{test: "${FOO:?baz} }}}", errMsg: "baz"},
121121
{test: "${FOO?baz} }}}", errMsg: "baz"},
122+
// nested variables
123+
{test: "${FOO:-${BAR:-${ZOT:-qix}}}", expected: "qix"},
124+
{test: "${FOO:-${BAR:-x}_test_${BAR:-y}}", expected: "x_test_y"},
125+
{test: "${FOO:-${BAR:-x}_test}", expected: "x_test"},
126+
{test: "${FOO:-${BAR:-${ZOT:-x}}_test}", expected: "x_test"},
122127
}
123128

124129
getServiceConfig := func(val string) map[string]interface{} {

template/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
var delimiter = "\\$"
2929
var substitutionNamed = "[_a-z][_a-z0-9]*"
3030

31-
var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?](.*}|[^}]*))?"
31+
var substitutionBraced = "[_a-z][_a-z0-9]*(?::?[-+?](.*))?"
3232

3333
var patternString = fmt.Sprintf(
3434
"%s(?i:(?P<escaped>%s)|(?P<named>%s)|{(?:(?P<braced>%s)}|(?P<invalid>)))",

0 commit comments

Comments
 (0)