2021-09-01 09:38:56 -05:00
|
|
|
//go:build wireinject
|
2021-08-25 08:11:22 -05:00
|
|
|
// +build wireinject
|
|
|
|
|
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/wire"
|
|
|
|
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
|
|
|
"github.com/grafana/grafana/pkg/api"
|
|
|
|
"github.com/grafana/grafana/pkg/api/routing"
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
2021-11-10 04:52:16 -06:00
|
|
|
"github.com/grafana/grafana/pkg/expr"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/httpclient"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/httpclient/httpclientprovider"
|
2021-08-31 10:05:45 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/kvstore"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/infra/localcache"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/remotecache"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/serverlock"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/tracing"
|
|
|
|
"github.com/grafana/grafana/pkg/infra/usagestats"
|
2021-09-21 13:50:37 -05:00
|
|
|
uss "github.com/grafana/grafana/pkg/infra/usagestats/service"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/login/social"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager"
|
2021-11-01 04:53:33 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/manager/loader"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/plugins/plugincontext"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins/plugindashboards"
|
|
|
|
"github.com/grafana/grafana/pkg/services/alerting"
|
|
|
|
"github.com/grafana/grafana/pkg/services/auth/jwt"
|
|
|
|
"github.com/grafana/grafana/pkg/services/cleanup"
|
|
|
|
"github.com/grafana/grafana/pkg/services/contexthandler"
|
2021-09-01 06:05:15 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/datasourceproxy"
|
2021-10-07 09:33:50 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/datasources"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/hooks"
|
|
|
|
"github.com/grafana/grafana/pkg/services/libraryelements"
|
|
|
|
"github.com/grafana/grafana/pkg/services/librarypanels"
|
|
|
|
"github.com/grafana/grafana/pkg/services/live"
|
|
|
|
"github.com/grafana/grafana/pkg/services/live/pushhttp"
|
|
|
|
"github.com/grafana/grafana/pkg/services/login"
|
|
|
|
"github.com/grafana/grafana/pkg/services/login/authinfoservice"
|
|
|
|
"github.com/grafana/grafana/pkg/services/login/loginservice"
|
|
|
|
"github.com/grafana/grafana/pkg/services/ngalert"
|
|
|
|
ngmetrics "github.com/grafana/grafana/pkg/services/ngalert/metrics"
|
|
|
|
"github.com/grafana/grafana/pkg/services/notifications"
|
|
|
|
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
2021-10-07 09:33:50 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/pluginsettings"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/quota"
|
|
|
|
"github.com/grafana/grafana/pkg/services/rendering"
|
|
|
|
"github.com/grafana/grafana/pkg/services/schemaloader"
|
|
|
|
"github.com/grafana/grafana/pkg/services/search"
|
2021-10-01 07:39:57 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/secrets"
|
2021-10-12 09:08:07 -05:00
|
|
|
secretsDatabase "github.com/grafana/grafana/pkg/services/secrets/database"
|
|
|
|
secretsManager "github.com/grafana/grafana/pkg/services/secrets/manager"
|
2021-11-11 09:10:24 -06:00
|
|
|
"github.com/grafana/grafana/pkg/services/serviceaccounts"
|
|
|
|
serviceaccountsmanager "github.com/grafana/grafana/pkg/services/serviceaccounts/manager"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/shorturls"
|
|
|
|
"github.com/grafana/grafana/pkg/services/sqlstore"
|
2021-11-01 04:53:33 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/updatechecker"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/azuremonitor"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudmonitoring"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/cloudwatch"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/elasticsearch"
|
2021-09-10 09:44:47 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/graphite"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/influxdb"
|
2021-11-10 04:52:16 -06:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/legacydata"
|
|
|
|
legacydataservice "github.com/grafana/grafana/pkg/tsdb/legacydata/service"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/loki"
|
2021-09-07 02:35:37 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/mssql"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/mysql"
|
2021-08-25 08:11:22 -05:00
|
|
|
"github.com/grafana/grafana/pkg/tsdb/opentsdb"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/postgres"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/prometheus"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/tempo"
|
|
|
|
"github.com/grafana/grafana/pkg/tsdb/testdatasource"
|
|
|
|
)
|
|
|
|
|
|
|
|
var wireBasicSet = wire.NewSet(
|
2021-11-10 04:52:16 -06:00
|
|
|
legacydataservice.ProvideService,
|
|
|
|
wire.Bind(new(legacydata.RequestHandler), new(*legacydataservice.Service)),
|
2021-08-25 08:11:22 -05:00
|
|
|
alerting.ProvideAlertEngine,
|
|
|
|
wire.Bind(new(alerting.UsageStatsQuerier), new(*alerting.AlertEngine)),
|
|
|
|
setting.NewCfgFromArgs,
|
|
|
|
New,
|
|
|
|
api.ProvideHTTPServer,
|
|
|
|
bus.ProvideBus,
|
|
|
|
wire.Bind(new(bus.Bus), new(*bus.InProcBus)),
|
|
|
|
rendering.ProvideService,
|
|
|
|
wire.Bind(new(rendering.Service), new(*rendering.RenderingService)),
|
|
|
|
routing.ProvideRegister,
|
|
|
|
wire.Bind(new(routing.RouteRegister), new(*routing.RouteRegisterImpl)),
|
|
|
|
hooks.ProvideService,
|
2021-08-31 10:05:45 -05:00
|
|
|
kvstore.ProvideService,
|
2021-08-25 08:11:22 -05:00
|
|
|
localcache.ProvideService,
|
2021-11-01 04:53:33 -05:00
|
|
|
updatechecker.ProvideService,
|
2021-09-21 13:50:37 -05:00
|
|
|
uss.ProvideService,
|
|
|
|
wire.Bind(new(usagestats.Service), new(*uss.UsageStats)),
|
2021-08-25 08:11:22 -05:00
|
|
|
manager.ProvideService,
|
2021-11-01 04:53:33 -05:00
|
|
|
wire.Bind(new(plugins.Client), new(*manager.PluginManager)),
|
|
|
|
wire.Bind(new(plugins.Store), new(*manager.PluginManager)),
|
|
|
|
wire.Bind(new(plugins.CoreBackendRegistrar), new(*manager.PluginManager)),
|
|
|
|
wire.Bind(new(plugins.StaticRouteResolver), new(*manager.PluginManager)),
|
|
|
|
wire.Bind(new(plugins.PluginDashboardManager), new(*manager.PluginManager)),
|
|
|
|
wire.Bind(new(plugins.RendererManager), new(*manager.PluginManager)),
|
|
|
|
loader.ProvideService,
|
|
|
|
wire.Bind(new(plugins.Loader), new(*loader.Loader)),
|
|
|
|
wire.Bind(new(plugins.ErrorResolver), new(*loader.Loader)),
|
2021-08-25 08:11:22 -05:00
|
|
|
cloudwatch.ProvideService,
|
|
|
|
cloudwatch.ProvideLogsService,
|
|
|
|
cloudmonitoring.ProvideService,
|
|
|
|
azuremonitor.ProvideService,
|
|
|
|
postgres.ProvideService,
|
2021-09-07 02:35:37 -05:00
|
|
|
mysql.ProvideService,
|
|
|
|
mssql.ProvideService,
|
2021-08-25 08:11:22 -05:00
|
|
|
httpclientprovider.New,
|
|
|
|
wire.Bind(new(httpclient.Provider), new(*sdkhttpclient.Provider)),
|
|
|
|
serverlock.ProvideService,
|
|
|
|
cleanup.ProvideService,
|
|
|
|
shorturls.ProvideService,
|
|
|
|
wire.Bind(new(shorturls.Service), new(*shorturls.ShortURLService)),
|
|
|
|
quota.ProvideService,
|
|
|
|
remotecache.ProvideService,
|
|
|
|
loginservice.ProvideService,
|
|
|
|
wire.Bind(new(login.Service), new(*loginservice.Implementation)),
|
|
|
|
authinfoservice.ProvideAuthInfoService,
|
|
|
|
wire.Bind(new(login.AuthInfoService), new(*authinfoservice.Implementation)),
|
|
|
|
datasourceproxy.ProvideService,
|
|
|
|
search.ProvideService,
|
|
|
|
live.ProvideService,
|
|
|
|
pushhttp.ProvideService,
|
|
|
|
plugincontext.ProvideService,
|
|
|
|
contexthandler.ProvideService,
|
|
|
|
jwt.ProvideService,
|
|
|
|
wire.Bind(new(models.JWTService), new(*jwt.AuthService)),
|
|
|
|
plugindashboards.ProvideService,
|
|
|
|
schemaloader.ProvideService,
|
|
|
|
ngalert.ProvideService,
|
|
|
|
librarypanels.ProvideService,
|
|
|
|
wire.Bind(new(librarypanels.Service), new(*librarypanels.LibraryPanelService)),
|
|
|
|
libraryelements.ProvideService,
|
|
|
|
wire.Bind(new(libraryelements.Service), new(*libraryelements.LibraryElementService)),
|
|
|
|
notifications.ProvideService,
|
|
|
|
tracing.ProvideService,
|
|
|
|
metrics.ProvideService,
|
|
|
|
testdatasource.ProvideService,
|
|
|
|
opentsdb.ProvideService,
|
|
|
|
social.ProvideService,
|
|
|
|
influxdb.ProvideService,
|
|
|
|
wire.Bind(new(social.Service), new(*social.SocialService)),
|
|
|
|
oauthtoken.ProvideService,
|
|
|
|
wire.Bind(new(oauthtoken.OAuthTokenService), new(*oauthtoken.Service)),
|
|
|
|
tempo.ProvideService,
|
|
|
|
loki.ProvideService,
|
|
|
|
graphite.ProvideService,
|
|
|
|
prometheus.ProvideService,
|
|
|
|
elasticsearch.ProvideService,
|
2021-10-12 09:08:07 -05:00
|
|
|
secretsManager.ProvideSecretsService,
|
|
|
|
wire.Bind(new(secrets.Service), new(*secretsManager.SecretsService)),
|
2021-11-04 12:25:01 -05:00
|
|
|
wire.Bind(new(secrets.ProvidersRegistrar), new(*secretsManager.SecretsService)),
|
2021-10-12 09:08:07 -05:00
|
|
|
secretsDatabase.ProvideSecretsStore,
|
|
|
|
wire.Bind(new(secrets.Store), new(*secretsDatabase.SecretsStoreImpl)),
|
2021-09-10 09:44:47 -05:00
|
|
|
grafanads.ProvideService,
|
2021-09-01 06:05:15 -05:00
|
|
|
dashboardsnapshots.ProvideService,
|
2021-10-07 09:33:50 -05:00
|
|
|
datasources.ProvideService,
|
|
|
|
pluginsettings.ProvideService,
|
|
|
|
alerting.ProvideService,
|
2021-11-11 09:10:24 -06:00
|
|
|
serviceaccountsmanager.ProvideServiceAccountsService,
|
|
|
|
wire.Bind(new(serviceaccounts.Service), new(*serviceaccountsmanager.ServiceAccountsService)),
|
2021-11-10 04:52:16 -06:00
|
|
|
expr.ProvideService,
|
2021-08-25 08:11:22 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
var wireSet = wire.NewSet(
|
|
|
|
wireBasicSet,
|
|
|
|
sqlstore.ProvideService,
|
|
|
|
ngmetrics.ProvideService,
|
|
|
|
)
|
|
|
|
|
|
|
|
var wireTestSet = wire.NewSet(
|
|
|
|
wireBasicSet,
|
|
|
|
ProvideTestEnv,
|
|
|
|
sqlstore.ProvideServiceForTests,
|
|
|
|
ngmetrics.ProvideServiceForTest,
|
|
|
|
)
|
|
|
|
|
|
|
|
func Initialize(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions) (*Server, error) {
|
|
|
|
wire.Build(wireExtsSet)
|
|
|
|
return &Server{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func InitializeForTest(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions) (*TestEnv, error) {
|
|
|
|
wire.Build(wireExtsTestSet)
|
|
|
|
return &TestEnv{Server: &Server{}, SQLStore: &sqlstore.SQLStore{}}, nil
|
|
|
|
}
|