Commit 579abad9 by Carl Bergquist Committed by GitHub

Plugins: Return jsondetails as an json object instead of raw json on datasource…

Plugins: Return jsondetails as an json object instead of raw json on datasource healthchecks. (#22859)
parent 60e3437f
package api
import (
"encoding/json"
"sort"
"github.com/grafana/grafana/pkg/api/dtos"
......@@ -385,10 +386,22 @@ func (hs *HTTPServer) CheckDatasourceHealth(c *models.ReqContext) {
return
}
var jsonDetails map[string]interface{}
payload := map[string]interface{}{
"status": resp.Status.String(),
"message": resp.Message,
"jsonDetails": resp.JSONDetails,
"details": jsonDetails,
}
// Unmarshal JSONDetails if it's not empty.
if len(resp.JSONDetails) > 0 {
err = json.Unmarshal(resp.JSONDetails, &jsonDetails)
if err != nil {
c.JsonApiErr(500, "Failed to unmarshal detailed response from backend plugin", err)
return
}
payload["details"] = jsonDetails
}
if resp.Status != backendplugin.HealthStatusOk {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment