Expressions: use datasource model from the query (#41376)
* refactor datasource loading * refactor datasource loading * pass uid * use dscache in alerting to get DS * remove expr/translate pacakge * remove dup injection entry * fix DS type on metrics endpoint, remove SQL DS lookup inside SSE * update test and adapter * comment fix * Make eval run as admin when getting datasource info Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> * fmt and comment * remove unncessary/redundant code Co-authored-by: Kyle Brandt <kyle@grafana.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
Kyle Brandt
Santiago
parent
1745cd8186
commit
2754e4fdf0
@@ -2,6 +2,8 @@
|
||||
package adapters
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
@@ -9,9 +11,13 @@ import (
|
||||
// ModelToInstanceSettings converts a models.DataSource to a backend.DataSourceInstanceSettings.
|
||||
func ModelToInstanceSettings(ds *models.DataSource, decryptFn func(map[string][]byte) map[string]string,
|
||||
) (*backend.DataSourceInstanceSettings, error) {
|
||||
jsonDataBytes, err := ds.JsonData.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
var jsonDataBytes json.RawMessage
|
||||
if ds.JsonData != nil {
|
||||
var err error
|
||||
jsonDataBytes, err = ds.JsonData.MarshalJSON()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &backend.DataSourceInstanceSettings{
|
||||
|
||||
Reference in New Issue
Block a user