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
@@ -39,18 +39,24 @@ func TestService(t *testing.T) {
|
||||
}
|
||||
|
||||
bus.AddHandlerCtx("test", func(_ context.Context, query *models.GetDataSourceQuery) error {
|
||||
query.Result = &models.DataSource{Id: 1, OrgId: 1, Type: "test", JsonData: simplejson.New()}
|
||||
query.Result = &models.DataSource{Uid: "1", OrgId: 1, Type: "test", JsonData: simplejson.New()}
|
||||
return nil
|
||||
})
|
||||
|
||||
queries := []Query{
|
||||
{
|
||||
RefID: "A",
|
||||
JSON: json.RawMessage(`{ "datasource": "test", "datasourceId": 1, "orgId": 1, "intervalMs": 1000, "maxDataPoints": 1000 }`),
|
||||
DataSource: &models.DataSource{
|
||||
OrgId: 1,
|
||||
Uid: "test",
|
||||
Type: "test",
|
||||
},
|
||||
JSON: json.RawMessage(`{ "datasource": { "uid": "1" }, "intervalMs": 1000, "maxDataPoints": 1000 }`),
|
||||
},
|
||||
{
|
||||
RefID: "B",
|
||||
JSON: json.RawMessage(`{ "datasource": "__expr__", "datasourceId": -100, "type": "math", "expression": "$A * 2" }`),
|
||||
RefID: "B",
|
||||
DataSource: DataSourceModel(),
|
||||
JSON: json.RawMessage(`{ "datasource": { "uid": "__expr__", "type": "__expr__"}, "type": "math", "expression": "$A * 2" }`),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user