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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user