[v9.4.x] Plugins: Prefer to use the data source UID when querying (#62789)

Plugins: Prefer to use the data source UID when querying (#62776)

(cherry picked from commit 68862ce3e8)

Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2023-02-02 15:02:06 +00:00
committed by GitHub
co-authored by Andres Martinez Gotor
parent 022abcb47d
commit 190c3aad58
3 changed files with 37 additions and 9 deletions
+6 -6
View File
@@ -322,18 +322,18 @@ func (s *Service) getDataSourceFromQuery(ctx context.Context, user *user.SignedI
return grafanads.DataSourceModel(user.OrgID), nil
}
// use datasourceId if it exists
id := query.Get("datasourceId").MustInt64(0)
if id > 0 {
ds, err = s.dataSourceCache.GetDatasource(ctx, id, user, skipCache)
if uid != "" {
ds, err = s.dataSourceCache.GetDatasourceByUID(ctx, uid, user, skipCache)
if err != nil {
return nil, err
}
return ds, nil
}
if uid != "" {
ds, err = s.dataSourceCache.GetDatasourceByUID(ctx, uid, user, skipCache)
// use datasourceId if it exists
id := query.Get("datasourceId").MustInt64(0)
if id > 0 {
ds, err = s.dataSourceCache.GetDatasource(ctx, id, user, skipCache)
if err != nil {
return nil, err
}