diff --git a/template/variables.go b/template/variables.go index fb32f9c3..84edee59 100644 --- a/template/variables.go +++ b/template/variables.go @@ -108,6 +108,9 @@ func extractVariable(value interface{}, pattern *regexp.Regexp) ([]Variable, boo if r >= 'A' && r <= 'Z' { return false } + if r >= '0' && r <= '9' { + return false + } if r == '_' { return false } diff --git a/template/variables_test.go b/template/variables_test.go index 00133d5a..7239b016 100644 --- a/template/variables_test.go +++ b/template/variables_test.go @@ -50,6 +50,15 @@ func TestExtractVariables(t *testing.T) { "bar": {Name: "bar"}, }, }, + { + name: "variable-without-curly-braces-and-with-number-suffix", + dict: map[string]interface{}{ + "foo": "$bar_1", + }, + expected: map[string]Variable{ + "bar_1": {Name: "bar_1"}, + }, + }, { name: "variable", dict: map[string]interface{}{ @@ -68,6 +77,15 @@ func TestExtractVariables(t *testing.T) { "bar": {Name: "bar", DefaultValue: "", Required: true}, }, }, + { + name: "required-variable-with-number-suffix", + dict: map[string]interface{}{ + "foo": "${bar_1?:foo}", + }, + expected: map[string]Variable{ + "bar_1": {Name: "bar_1", DefaultValue: "", Required: true}, + }, + }, { name: "required-variable2", dict: map[string]interface{}{ @@ -95,6 +113,24 @@ func TestExtractVariables(t *testing.T) { "bar": {Name: "bar", DefaultValue: "foo"}, }, }, + { + name: "default-variable-with-number-suffix", + dict: map[string]interface{}{ + "foo": "${bar_1:-foo}", + }, + expected: map[string]Variable{ + "bar_1": {Name: "bar_1", DefaultValue: "foo"}, + }, + }, + { + name: "default-variable2-with-number-suffix", + dict: map[string]interface{}{ + "foo": "${bar_1-foo}", + }, + expected: map[string]Variable{ + "bar_1": {Name: "bar_1", DefaultValue: "foo"}, + }, + }, { name: "multiple-values", dict: map[string]interface{}{