Import: fix dashboard imports with expressions (#43630) (#43680)

(cherry picked from commit b09d498484)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-01-04 10:09:41 -08:00
committed by GitHub
co-authored by Ryan McKinley
parent a524f34e84
commit 2af71f339c
2 changed files with 12 additions and 0 deletions
+8
View File
@@ -6,6 +6,7 @@ import (
"regexp"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/expr"
"github.com/grafana/grafana/pkg/plugins"
)
@@ -47,6 +48,13 @@ func (e *DashTemplateEvaluator) Eval() (*simplejson.Json, error) {
inputType := inputDefJson.Get("type").MustString()
input := e.findInput(inputName, inputType)
// force expressions value to `__expr__`
if inputDefJson.Get("pluginId").MustString() == expr.DatasourceType {
input = &plugins.ImportDashboardInput{
Value: expr.DatasourceType,
}
}
if input == nil {
return nil, &DashboardInputMissingError{VariableName: inputName}
}