mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Datasources: Add wireset for datasource.DataSourceAPIBuilder (#80914)
tidy up
This commit is contained in:
parent
f3c64a7337
commit
2a0f1900d5
@ -12,9 +12,9 @@ import (
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
netutils "k8s.io/utils/net"
|
||||
|
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/example"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/featuretoggle"
|
||||
"github.com/grafana/grafana/pkg/server"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
grafanaAPIServer "github.com/grafana/grafana/pkg/services/grafana-apiserver"
|
||||
"github.com/grafana/grafana/pkg/services/grafana-apiserver/utils"
|
||||
@ -58,7 +58,7 @@ func (o *APIServerOptions) loadAPIGroupBuilders(args []string) error {
|
||||
}
|
||||
o.builders = append(o.builders, featuretoggle.NewFeatureFlagAPIBuilder(features))
|
||||
case "testdata.datasource.grafana.app":
|
||||
ds, err := datasource.NewStandaloneDatasource(g)
|
||||
ds, err := server.InitializeDataSourceAPIServer(g)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -8,16 +8,13 @@ import (
|
||||
|
||||
common "github.com/grafana/grafana/pkg/apis/common/v0alpha1"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
testdatasource "github.com/grafana/grafana/pkg/tsdb/grafana-testdata-datasource"
|
||||
)
|
||||
|
||||
// NewStandaloneDatasource is a helper function to create a new datasource API server for a group.
|
||||
// This currently has no dependencies and only works for testdata. In future iterations
|
||||
// this will include here (or elsewhere) versions that can load config from HG api or
|
||||
// the remote SQL directly.
|
||||
func NewStandaloneDatasource(group string) (*DataSourceAPIBuilder, error) {
|
||||
// NewTestDataAPIServer is a helper function to create a new datasource API server for a group.
|
||||
// This currently builds its dependencies manually and only works for testdata.
|
||||
func NewTestDataAPIServer(group string) (*DataSourceAPIBuilder, error) {
|
||||
pluginID := "grafana-testdata-datasource"
|
||||
|
||||
if group != "testdata.datasource.grafana.app" {
|
||||
@ -31,7 +28,7 @@ func NewStandaloneDatasource(group string) (*DataSourceAPIBuilder, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_, pluginStore, dsService, dsCache, err := apiBuilderServices(cfg, pluginID)
|
||||
accessControl, pluginStore, dsService, dsCache, err := apiBuilderServices(cfg, pluginID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -49,7 +46,7 @@ func NewStandaloneDatasource(group string) (*DataSourceAPIBuilder, error) {
|
||||
td.JSONData,
|
||||
NewQuerierProvider(testsDataQuerierFactory),
|
||||
&TestDataPluginContextProvider{},
|
||||
acimpl.ProvideAccessControl(cfg),
|
||||
accessControl,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/middleware/csrf"
|
||||
"github.com/grafana/grafana/pkg/middleware/loggermw"
|
||||
apiregistry "github.com/grafana/grafana/pkg/registry/apis"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
@ -459,3 +460,8 @@ func InitializeModuleServer(cfg *setting.Cfg, opts Options, apiOpts api.ServerOp
|
||||
wire.Build(wireExtsModuleServerSet)
|
||||
return &ModuleServer{}, nil
|
||||
}
|
||||
|
||||
func InitializeDataSourceAPIServer(group string) (*datasource.DataSourceAPIBuilder, error) {
|
||||
wire.Build(wireExtsDataSourceApiServerSet)
|
||||
return &datasource.DataSourceAPIBuilder{}, nil
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/manager"
|
||||
"github.com/grafana/grafana/pkg/registry"
|
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource"
|
||||
"github.com/grafana/grafana/pkg/registry/backgroundsvcs"
|
||||
"github.com/grafana/grafana/pkg/registry/usagestatssvcs"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
@ -137,3 +138,7 @@ var wireExtsModuleServerSet = wire.NewSet(
|
||||
NewModule,
|
||||
wireExtsBaseCLISet,
|
||||
)
|
||||
|
||||
var wireExtsDataSourceApiServerSet = wire.NewSet(
|
||||
datasource.NewTestDataAPIServer,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user