mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Server: Remove unused services (#62015)
remove unused entries Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com> Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
@@ -60,7 +60,9 @@ type OAuthInfo struct {
|
|||||||
AutoLogin bool
|
AutoLogin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager) *SocialService {
|
func ProvideService(cfg *setting.Cfg,
|
||||||
|
features *featuremgmt.FeatureManager,
|
||||||
|
) *SocialService {
|
||||||
ss := SocialService{
|
ss := SocialService{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
oAuthProvider: make(map[string]*OAuthInfo),
|
oAuthProvider: make(map[string]*OAuthInfo),
|
||||||
@@ -227,6 +229,7 @@ func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager) *Soc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ss
|
return &ss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,17 +13,13 @@ import (
|
|||||||
|
|
||||||
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
|
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
"github.com/grafana/grafana/pkg/services/loginattempt"
|
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/api"
|
"github.com/grafana/grafana/pkg/api"
|
||||||
_ "github.com/grafana/grafana/pkg/extensions"
|
_ "github.com/grafana/grafana/pkg/extensions"
|
||||||
"github.com/grafana/grafana/pkg/infra/log"
|
"github.com/grafana/grafana/pkg/infra/log"
|
||||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||||
"github.com/grafana/grafana/pkg/login"
|
|
||||||
"github.com/grafana/grafana/pkg/login/social"
|
|
||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/services/provisioning"
|
"github.com/grafana/grafana/pkg/services/provisioning"
|
||||||
"github.com/grafana/grafana/pkg/services/user"
|
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
@@ -43,10 +39,9 @@ type Options struct {
|
|||||||
func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
|
func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
|
||||||
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
|
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
|
||||||
usageStatsProvidersRegistry registry.UsageStatsProvidersRegistry, statsCollectorService *statscollector.Service,
|
usageStatsProvidersRegistry registry.UsageStatsProvidersRegistry, statsCollectorService *statscollector.Service,
|
||||||
userService user.Service, loginAttemptService loginattempt.Service,
|
|
||||||
) (*Server, error) {
|
) (*Server, error) {
|
||||||
statsCollectorService.RegisterProviders(usageStatsProvidersRegistry.GetServices())
|
statsCollectorService.RegisterProviders(usageStatsProvidersRegistry.GetServices())
|
||||||
s, err := newServer(opts, cfg, httpServer, roleRegistry, provisioningService, backgroundServiceProvider, userService, loginAttemptService)
|
s, err := newServer(opts, cfg, httpServer, roleRegistry, provisioningService, backgroundServiceProvider)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -59,7 +54,7 @@ func New(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newServer(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
|
func newServer(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleRegistry accesscontrol.RoleRegistry,
|
||||||
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry, userService user.Service, loginAttemptService loginattempt.Service,
|
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
|
||||||
) (*Server, error) {
|
) (*Server, error) {
|
||||||
rootCtx, shutdownFn := context.WithCancel(context.Background())
|
rootCtx, shutdownFn := context.WithCancel(context.Background())
|
||||||
childRoutines, childCtx := errgroup.WithContext(rootCtx)
|
childRoutines, childCtx := errgroup.WithContext(rootCtx)
|
||||||
@@ -79,8 +74,6 @@ func newServer(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleR
|
|||||||
commit: opts.Commit,
|
commit: opts.Commit,
|
||||||
buildBranch: opts.BuildBranch,
|
buildBranch: opts.BuildBranch,
|
||||||
backgroundServices: backgroundServiceProvider.GetServices(),
|
backgroundServices: backgroundServiceProvider.GetServices(),
|
||||||
userService: userService,
|
|
||||||
loginAttemptService: loginAttemptService,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
@@ -107,8 +100,6 @@ type Server struct {
|
|||||||
HTTPServer *api.HTTPServer
|
HTTPServer *api.HTTPServer
|
||||||
roleRegistry accesscontrol.RoleRegistry
|
roleRegistry accesscontrol.RoleRegistry
|
||||||
provisioningService provisioning.ProvisioningService
|
provisioningService provisioning.ProvisioningService
|
||||||
userService user.Service
|
|
||||||
loginAttemptService loginattempt.Service
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init initializes the server and its services.
|
// init initializes the server and its services.
|
||||||
@@ -129,9 +120,6 @@ func (s *Server) init() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
login.ProvideService(s.HTTPServer.SQLStore, s.HTTPServer.Login, s.loginAttemptService, s.userService)
|
|
||||||
social.ProvideService(s.cfg, s.HTTPServer.Features)
|
|
||||||
|
|
||||||
if err := s.roleRegistry.RegisterFixedRoles(s.context); err != nil {
|
if err := s.roleRegistry.RegisterFixedRoles(s.context); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
|
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
|
||||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||||
"github.com/grafana/grafana/pkg/services/user/usertest"
|
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
@@ -48,7 +47,7 @@ func (s *testService) IsDisabled() bool {
|
|||||||
|
|
||||||
func testServer(t *testing.T, services ...registry.BackgroundService) *Server {
|
func testServer(t *testing.T, services ...registry.BackgroundService) *Server {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...), usertest.NewUserServiceFake(), nil)
|
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
// Required to skip configuration initialization that causes
|
// Required to skip configuration initialization that causes
|
||||||
// DI errors in this test.
|
// DI errors in this test.
|
||||||
|
|||||||
@@ -32,12 +32,20 @@ type Bundle struct {
|
|||||||
type CollectorFunc func(context.Context) (*SupportItem, error)
|
type CollectorFunc func(context.Context) (*SupportItem, error)
|
||||||
|
|
||||||
type Collector struct {
|
type Collector struct {
|
||||||
UID string `json:"uid"`
|
// UID is a unique identifier for the collector.
|
||||||
DisplayName string `json:"displayName"`
|
UID string `json:"uid"`
|
||||||
Description string `json:"description"`
|
// DisplayName is the name of the collector. User facing.
|
||||||
IncludedByDefault bool `json:"includedByDefault"`
|
DisplayName string `json:"displayName"`
|
||||||
Default bool `json:"default"`
|
// Description is a description of the collector. User facing.
|
||||||
Fn CollectorFunc `json:"-"`
|
Description string `json:"description"`
|
||||||
|
// IncludedByDefault determines if the collector is included by default.
|
||||||
|
// User cannot override this.
|
||||||
|
IncludedByDefault bool `json:"includedByDefault"`
|
||||||
|
// Default determines if the collector is included by default.
|
||||||
|
// User can override this.
|
||||||
|
Default bool `json:"default"`
|
||||||
|
// Fn is the function that collects the support item.
|
||||||
|
Fn CollectorFunc `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
|
|||||||
Reference in New Issue
Block a user