diff --git a/pkg/registry/apis/datasource/register.go b/pkg/registry/apis/datasource/register.go index 9cc158188b0..c9d67af4786 100644 --- a/pkg/registry/apis/datasource/register.go +++ b/pkg/registry/apis/datasource/register.go @@ -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) { diff --git a/pkg/registry/apis/datasource/sub_health.go b/pkg/registry/apis/datasource/sub_health.go index ebd4fa0b8e8..ede7aeca7ce 100644 --- a/pkg/registry/apis/datasource/sub_health.go +++ b/pkg/registry/apis/datasource/sub_health.go @@ -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, diff --git a/pkg/registry/apis/datasource/sub_query.go b/pkg/registry/apis/datasource/sub_query.go index 14c4c410bfb..eda371d7ed5 100644 --- a/pkg/registry/apis/datasource/sub_query.go +++ b/pkg/registry/apis/datasource/sub_query.go @@ -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) diff --git a/pkg/registry/apis/datasource/sub_resource.go b/pkg/registry/apis/datasource/sub_resource.go index 67766ab3a45..751ddd43214 100644 --- a/pkg/registry/apis/datasource/sub_resource.go +++ b/pkg/registry/apis/datasource/sub_resource.go @@ -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)