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

This commit is contained in:
Sofia Papagiannaki 2020-07-24 11:12:44 +03:00 committed by GitHub
parent ca9418ea80
commit 5e73a92327
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import (
"github.com/grafana/grafana/pkg/services/dashboards" "github.com/grafana/grafana/pkg/services/dashboards"
) )
var varRegex = regexp.MustCompile(`(\$\{.+\})`) var varRegex = regexp.MustCompile(`(\$\{.+?\})`)
type ImportDashboardCommand struct { type ImportDashboardCommand struct {
Dashboard *simplejson.Json Dashboard *simplejson.Json

View File

@ -58,7 +58,7 @@ func TestDashboardImport(t *testing.T) {
} }
], ],
"test": { "test": {
"prop": "${DS_NAME}" "prop": "${DS_NAME}_${DS_NAME}"
} }
}`)) }`))
@ -73,7 +73,7 @@ func TestDashboardImport(t *testing.T) {
So(err, ShouldBeNil) So(err, ShouldBeNil)
Convey("should render template", func() { 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() { Convey("should not include inputs in output", func() {