DataSources: Add datasource fetching + querying interface (#80749)

* first pass

* separate oss + enterprise

* tidy things up

* add ctx

* fix tests

* use standalone svcs

* mv plugin context provide

* fix wire

* fix import
This commit is contained in:
Will Browne
2024-01-19 15:56:52 +01:00
committed by GitHub
parent bb0fa4f99a
commit 3f30cbf91c
21 changed files with 342 additions and 196 deletions
+5 -8
View File
@@ -8,10 +8,12 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
"github.com/grafana/grafana/pkg/plugins"
)
type subProxyREST struct {
builder *DataSourceAPIBuilder
pluginJSON plugins.JSONData
}
var _ = rest.Connecter(&subProxyREST{})
@@ -25,7 +27,7 @@ func (r *subProxyREST) Destroy() {}
func (r *subProxyREST) ConnectMethods() []string {
unique := map[string]bool{}
methods := []string{}
for _, r := range r.builder.plugin.Routes {
for _, r := range r.pluginJSON.Routes {
if unique[r.Method] {
continue
}
@@ -40,12 +42,7 @@ func (r *subProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
}
func (r *subProxyREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
pluginCtx, err := r.builder.getDataSourcePluginContext(ctx, name)
if err != nil {
return nil, err
}
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
responder.Error(fmt.Errorf("TODO, proxy: " + pluginCtx.PluginID))
responder.Error(fmt.Errorf("TODO, proxy: " + r.pluginJSON.ID))
}), nil
}