mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
unified: allow customising the ProvideUnifiedStorageClient (#100704)
* unified: allow customising the ProvideUnifiedStorageClient * fix go mod
This commit is contained in:
@@ -187,14 +187,15 @@ func promptYesNo(prompt string) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newUnifiedClient(cfg *setting.Cfg, sqlStore db.DB) (resource.ResourceClient, error) {
|
func newUnifiedClient(cfg *setting.Cfg, sqlStore db.DB) (resource.ResourceClient, error) {
|
||||||
return unified.ProvideUnifiedStorageClient(cfg,
|
return unified.ProvideUnifiedStorageClient(&unified.Options{
|
||||||
featuremgmt.WithFeatures(), // none??
|
Cfg: cfg,
|
||||||
sqlStore,
|
Features: featuremgmt.WithFeatures(), // none??
|
||||||
tracing.NewNoopTracerService(),
|
DB: sqlStore,
|
||||||
prometheus.NewPedanticRegistry(),
|
Tracer: tracing.NewNoopTracerService(),
|
||||||
authlib.FixedAccessClient(true), // always true!
|
Reg: prometheus.NewPedanticRegistry(),
|
||||||
nil, // document supplier
|
Authzc: authlib.FixedAccessClient(true), // always true!
|
||||||
)
|
Docs: nil, // document supplier
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func newParquetClient(file *os.File) (resource.BatchStoreClient, error) {
|
func newParquetClient(file *os.File) (resource.BatchStoreClient, error) {
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/user"
|
"github.com/grafana/grafana/pkg/services/user"
|
||||||
"github.com/grafana/grafana/pkg/services/user/userimpl"
|
"github.com/grafana/grafana/pkg/services/user/userimpl"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/storage/unified"
|
|
||||||
unifiedsearch "github.com/grafana/grafana/pkg/storage/unified/search"
|
unifiedsearch "github.com/grafana/grafana/pkg/storage/unified/search"
|
||||||
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
||||||
cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring"
|
cloudmonitoring "github.com/grafana/grafana/pkg/tsdb/cloud-monitoring"
|
||||||
@@ -214,7 +213,6 @@ var wireBasicSet = wire.NewSet(
|
|||||||
mysql.ProvideService,
|
mysql.ProvideService,
|
||||||
mssql.ProvideService,
|
mssql.ProvideService,
|
||||||
store.ProvideEntityEventsService,
|
store.ProvideEntityEventsService,
|
||||||
unified.ProvideUnifiedStorageClient,
|
|
||||||
httpclientprovider.New,
|
httpclientprovider.New,
|
||||||
wire.Bind(new(httpclient.Provider), new(*sdkhttpclient.Provider)),
|
wire.Bind(new(httpclient.Provider), new(*sdkhttpclient.Provider)),
|
||||||
serverlock.ProvideService,
|
serverlock.ProvideService,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/storage/unified"
|
||||||
search2 "github.com/grafana/grafana/pkg/storage/unified/search"
|
search2 "github.com/grafana/grafana/pkg/storage/unified/search"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||||
@@ -116,6 +117,8 @@ var wireExtsBasicSet = wire.NewSet(
|
|||||||
search2.ProvideDocumentBuilders,
|
search2.ProvideDocumentBuilders,
|
||||||
sandbox.ProvideService,
|
sandbox.ProvideService,
|
||||||
wire.Bind(new(sandbox.Sandbox), new(*sandbox.Service)),
|
wire.Bind(new(sandbox.Sandbox), new(*sandbox.Service)),
|
||||||
|
wire.Struct(new(unified.Options), "*"),
|
||||||
|
unified.ProvideUnifiedStorageClient,
|
||||||
)
|
)
|
||||||
|
|
||||||
var wireExtsSet = wire.NewSet(
|
var wireExtsSet = wire.NewSet(
|
||||||
|
|||||||
@@ -39,29 +39,31 @@ func GetResourceClient(ctx context.Context) resource.ResourceClient {
|
|||||||
return pkgResourceClient
|
return pkgResourceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Options struct {
|
||||||
|
Cfg *setting.Cfg
|
||||||
|
Features featuremgmt.FeatureToggles
|
||||||
|
DB infraDB.DB
|
||||||
|
Tracer tracing.Tracer
|
||||||
|
Reg prometheus.Registerer
|
||||||
|
Authzc types.AccessClient
|
||||||
|
Docs resource.DocumentBuilderSupplier
|
||||||
|
}
|
||||||
|
|
||||||
// This adds a UnifiedStorage client into the wire dependency tree
|
// This adds a UnifiedStorage client into the wire dependency tree
|
||||||
func ProvideUnifiedStorageClient(
|
func ProvideUnifiedStorageClient(opts *Options) (resource.ResourceClient, error) {
|
||||||
cfg *setting.Cfg,
|
|
||||||
features featuremgmt.FeatureToggles,
|
|
||||||
db infraDB.DB,
|
|
||||||
tracer tracing.Tracer,
|
|
||||||
reg prometheus.Registerer,
|
|
||||||
authzc types.AccessClient,
|
|
||||||
docs resource.DocumentBuilderSupplier,
|
|
||||||
) (resource.ResourceClient, error) {
|
|
||||||
// See: apiserver.ApplyGrafanaConfig(cfg, features, o)
|
// See: apiserver.ApplyGrafanaConfig(cfg, features, o)
|
||||||
apiserverCfg := cfg.SectionWithEnvOverrides("grafana-apiserver")
|
apiserverCfg := opts.Cfg.SectionWithEnvOverrides("grafana-apiserver")
|
||||||
client, err := newClient(options.StorageOptions{
|
client, err := newClient(options.StorageOptions{
|
||||||
StorageType: options.StorageType(apiserverCfg.Key("storage_type").MustString(string(options.StorageTypeUnified))),
|
StorageType: options.StorageType(apiserverCfg.Key("storage_type").MustString(string(options.StorageTypeUnified))),
|
||||||
DataPath: apiserverCfg.Key("storage_path").MustString(filepath.Join(cfg.DataPath, "grafana-apiserver")),
|
DataPath: apiserverCfg.Key("storage_path").MustString(filepath.Join(opts.Cfg.DataPath, "grafana-apiserver")),
|
||||||
Address: apiserverCfg.Key("address").MustString(""), // client address
|
Address: apiserverCfg.Key("address").MustString(""), // client address
|
||||||
BlobStoreURL: apiserverCfg.Key("blob_url").MustString(""),
|
BlobStoreURL: apiserverCfg.Key("blob_url").MustString(""),
|
||||||
}, cfg, features, db, tracer, reg, authzc, docs)
|
}, opts.Cfg, opts.Features, opts.DB, opts.Tracer, opts.Reg, opts.Authzc, opts.Docs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Used to get the folder stats
|
// Used to get the folder stats
|
||||||
client = federated.NewFederatedClient(
|
client = federated.NewFederatedClient(
|
||||||
client, // The original
|
client, // The original
|
||||||
legacysql.NewDatabaseProvider(db),
|
legacysql.NewDatabaseProvider(opts.DB),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user