mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 16:13:02 +08:00
Plugins: Set grafana config, plugin version and user agent on plugin requests (#75171)
* first pass * fixup * remove test line * fix tests * use new fields * fix imports + formatting * fix tests * rollback changes * undo whitespace * apply pr feedback
This commit is contained in:
@ -71,7 +71,7 @@ func queryData(ctx context.Context, queries []backend.DataQuery, dsInfo *es.Data
|
||||
}
|
||||
|
||||
func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.InstanceFactoryFunc {
|
||||
return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||
return func(_ context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||
jsonData := map[string]any{}
|
||||
err := json.Unmarshal(settings.JSONData, &jsonData)
|
||||
if err != nil {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package elasticsearch
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
@ -30,7 +31,7 @@ func TestNewInstanceSettings(t *testing.T) {
|
||||
JSONData: json.RawMessage(settingsJSON),
|
||||
}
|
||||
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(dsSettings)
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(context.Background(), dsSettings)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
@ -49,7 +50,7 @@ func TestNewInstanceSettings(t *testing.T) {
|
||||
JSONData: json.RawMessage(settingsJSON),
|
||||
}
|
||||
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(dsSettings)
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(context.Background(), dsSettings)
|
||||
require.EqualError(t, err, "timeField cannot be cast to string")
|
||||
})
|
||||
|
||||
@ -68,7 +69,7 @@ func TestNewInstanceSettings(t *testing.T) {
|
||||
JSONData: json.RawMessage(settingsJSON),
|
||||
}
|
||||
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(dsSettings)
|
||||
_, err = newInstanceSettings(httpclient.NewProvider())(context.Background(), dsSettings)
|
||||
require.EqualError(t, err, "elasticsearch time field name is required")
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user