mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 08:56:43 -06:00
Datasource API: Add config to ctx (#83386)
This commit is contained in:
parent
5756f365e3
commit
fc8a9aad22
@ -36,7 +36,7 @@ type DataSourceAPIBuilder struct {
|
||||
connectionResourceInfo common.ResourceInfo
|
||||
|
||||
pluginJSON plugins.JSONData
|
||||
client plugins.Client // will only ever be called with the same pluginid!
|
||||
client PluginClient // will only ever be called with the same pluginid!
|
||||
datasources PluginDatasourceProvider
|
||||
contextProvider PluginContextWrapper
|
||||
accessControl accesscontrol.AccessControl
|
||||
@ -82,9 +82,17 @@ func RegisterAPIService(
|
||||
return builder, nil // only used for wire
|
||||
}
|
||||
|
||||
// PluginClient is a subset of the plugins.Client interface with only the
|
||||
// functions supported (yet) by the datasource API
|
||||
type PluginClient interface {
|
||||
backend.QueryDataHandler
|
||||
backend.CheckHealthHandler
|
||||
backend.CallResourceHandler
|
||||
}
|
||||
|
||||
func NewDataSourceAPIBuilder(
|
||||
plugin plugins.JSONData,
|
||||
client plugins.Client,
|
||||
client PluginClient,
|
||||
datasources PluginDatasourceProvider,
|
||||
contextProvider PluginContextWrapper,
|
||||
accessControl accesscontrol.AccessControl) (*DataSourceAPIBuilder, error) {
|
||||
|
@ -40,6 +40,7 @@ func (r *subHealthREST) Connect(ctx context.Context, name string, opts runtime.O
|
||||
responder.Error(err)
|
||||
return
|
||||
}
|
||||
ctx = backend.WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig)
|
||||
|
||||
healthResponse, err := r.builder.client.CheckHealth(ctx, &backend.CheckHealthRequest{
|
||||
PluginContext: pluginCtx,
|
||||
|
@ -77,6 +77,7 @@ func (r *subQueryREST) Connect(ctx context.Context, name string, opts runtime.Ob
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx = backend.WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig)
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
queries, dsRef, err := r.readQueries(req)
|
||||
|
@ -50,6 +50,7 @@ func (r *subResourceREST) Connect(ctx context.Context, name string, opts runtime
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ctx = backend.WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig)
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
body, err := io.ReadAll(req.Body)
|
||||
|
Loading…
Reference in New Issue
Block a user