mirror of
https://github.com/grafana/grafana.git
synced 2025-01-01 11:47:05 -06:00
Search: handle a couple of corner cases when parsing dashboard data (#48521)
This commit is contained in:
parent
da035e823f
commit
87ae3e0644
@ -2,6 +2,7 @@ package extract
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strconv"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
)
|
||||
@ -38,8 +39,17 @@ func ReadDashboard(stream io.Reader, lookup DatasourceLookup) (*DashboardInfo, e
|
||||
dash.Description = iter.ReadString()
|
||||
|
||||
case "schemaVersion":
|
||||
dash.SchemaVersion = iter.ReadInt64()
|
||||
|
||||
switch iter.WhatIsNext() {
|
||||
case jsoniter.NumberValue:
|
||||
dash.SchemaVersion = iter.ReadInt64()
|
||||
case jsoniter.StringValue:
|
||||
val := iter.ReadString()
|
||||
if v, err := strconv.ParseInt(val, 10, 64); err == nil {
|
||||
dash.SchemaVersion = v
|
||||
}
|
||||
default:
|
||||
iter.Skip()
|
||||
}
|
||||
case "timezone":
|
||||
dash.TimeZone = iter.ReadString()
|
||||
|
||||
@ -176,8 +186,17 @@ func readPanelInfo(iter *jsoniter.Iterator, lookup DatasourceLookup) PanelInfo {
|
||||
targets.addDatasource(iter)
|
||||
|
||||
case "targets":
|
||||
for iter.ReadArray() {
|
||||
targets.addTarget(iter)
|
||||
switch iter.WhatIsNext() {
|
||||
case jsoniter.ArrayValue:
|
||||
for iter.ReadArray() {
|
||||
targets.addTarget(iter)
|
||||
}
|
||||
case jsoniter.ObjectValue:
|
||||
for f := iter.ReadObject(); f != ""; f = iter.ReadObject() {
|
||||
targets.addTarget(iter)
|
||||
}
|
||||
default:
|
||||
iter.Skip()
|
||||
}
|
||||
|
||||
case "transformations":
|
||||
|
Loading…
Reference in New Issue
Block a user