DashboardImport: Fix variable interpolation when property contains multiple variable expressions (#26574)

(cherry picked from commit 5e73a92327)
This commit is contained in:
Sofia Papagiannaki
2020-07-24 12:08:01 +02:00
committed by Leonard Gram
parent 9c7776cd58
commit ba5886d42c
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ func (this *DashTemplateEvaluator) findInput(varName string, varType string) *Im
func (this *DashTemplateEvaluator) Eval() (*simplejson.Json, error) {
this.result = simplejson.New()
this.variables = make(map[string]string)
this.varRegex, _ = regexp.Compile(`(\$\{.+\})`)
this.varRegex, _ = regexp.Compile(`(\$\{.+?\})`)
// check that we have all inputs we need
for _, inputDef := range this.template.Get("__inputs").MustArray() {
+2 -2
View File
@@ -58,7 +58,7 @@ func TestDashboardImport(t *testing.T) {
}
],
"test": {
"prop": "${DS_NAME}"
"prop": "${DS_NAME}_${DS_NAME}"
}
}`))
@@ -73,7 +73,7 @@ func TestDashboardImport(t *testing.T) {
So(err, ShouldBeNil)
Convey("should render template", func() {
So(res.GetPath("test", "prop").MustString(), ShouldEqual, "my-server")
So(res.GetPath("test", "prop").MustString(), ShouldEqual, "my-server_my-server")
})
Convey("should not include inputs in output", func() {