Plugins: Return jsondetails as an json object instead of raw json on datasource healthchecks. (#22859)

(cherry picked from commit 579abad9cc)
This commit is contained in:
Carl Bergquist
2020-03-19 12:27:02 +01:00
committed by Arve Knudsen
parent 3e88197f96
commit ea483c0ce1
+16 -3
View File
@@ -1,6 +1,7 @@
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,
"status": resp.Status.String(),
"message": resp.Message,
"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 {