DashboardImport: Fix variable interpolation when property contains multiple variable expressions (#26574)
(cherry picked from commit 5e73a92327)
This commit is contained in:
committed by
Leonard Gram
parent
9c7776cd58
commit
ba5886d42c
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user