mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 15:45:43 -06:00
Prometheus/Alerting: handle datasource.timeRange is nil case (#37888)
This commit is contained in:
parent
5ab8d6a3b9
commit
668f397a8e
@ -85,9 +85,18 @@ func newInstanceSettings() datasource.InstanceFactoryFunc {
|
||||
return nil, errors.New("no http method provided")
|
||||
}
|
||||
|
||||
timeInterval, ok := jsonData["timeInterval"].(string)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid time-interval provided")
|
||||
// timeInterval can be a string or can be missing.
|
||||
// if it is missing, we set it to empty-string
|
||||
|
||||
timeInterval := ""
|
||||
|
||||
timeIntervalJson := jsonData["timeInterval"]
|
||||
if timeIntervalJson != nil {
|
||||
// if it is not nil, it must be a string
|
||||
timeInterval, ok = timeIntervalJson.(string)
|
||||
if !ok {
|
||||
return nil, errors.New("invalid time-interval provided")
|
||||
}
|
||||
}
|
||||
|
||||
mdl := DatasourceInfo{
|
||||
|
Loading…
Reference in New Issue
Block a user