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:
Jo
2023-01-26 16:13:22 +01:00
committed by GitHub
parent 8bbef70363
commit 4bcd3b41ec
4 changed files with 21 additions and 23 deletions

View File

@@ -60,7 +60,9 @@ type OAuthInfo struct {
AutoLogin bool
}
func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager) *SocialService {
func ProvideService(cfg *setting.Cfg,
features *featuremgmt.FeatureManager,
) *SocialService {
ss := SocialService{
cfg: cfg,
oAuthProvider: make(map[string]*OAuthInfo),
@@ -227,6 +229,7 @@ func ProvideService(cfg *setting.Cfg, features *featuremgmt.FeatureManager) *Soc
}
}
}
return &ss
}

View File

@@ -13,17 +13,13 @@ import (
"github.com/grafana/grafana/pkg/infra/usagestats/statscollector"
"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/extensions"
"github.com/grafana/grafana/pkg/infra/log"
"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/services/provisioning"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/setting"
"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,
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
usageStatsProvidersRegistry registry.UsageStatsProvidersRegistry, statsCollectorService *statscollector.Service,
userService user.Service, loginAttemptService loginattempt.Service,
) (*Server, error) {
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 {
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,
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry, userService user.Service, loginAttemptService loginattempt.Service,
provisioningService provisioning.ProvisioningService, backgroundServiceProvider registry.BackgroundServiceRegistry,
) (*Server, error) {
rootCtx, shutdownFn := context.WithCancel(context.Background())
childRoutines, childCtx := errgroup.WithContext(rootCtx)
@@ -79,8 +74,6 @@ func newServer(opts Options, cfg *setting.Cfg, httpServer *api.HTTPServer, roleR
commit: opts.Commit,
buildBranch: opts.BuildBranch,
backgroundServices: backgroundServiceProvider.GetServices(),
userService: userService,
loginAttemptService: loginAttemptService,
}
return s, nil
@@ -107,8 +100,6 @@ type Server struct {
HTTPServer *api.HTTPServer
roleRegistry accesscontrol.RoleRegistry
provisioningService provisioning.ProvisioningService
userService user.Service
loginAttemptService loginattempt.Service
}
// init initializes the server and its services.
@@ -129,9 +120,6 @@ func (s *Server) init() error {
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 {
return err
}

View File

@@ -10,7 +10,6 @@ import (
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
"github.com/grafana/grafana/pkg/services/user/usertest"
"github.com/grafana/grafana/pkg/setting"
"github.com/stretchr/testify/require"
)
@@ -48,7 +47,7 @@ func (s *testService) IsDisabled() bool {
func testServer(t *testing.T, services ...registry.BackgroundService) *Server {
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)
// Required to skip configuration initialization that causes
// DI errors in this test.

View File

@@ -32,12 +32,20 @@ type Bundle struct {
type CollectorFunc func(context.Context) (*SupportItem, error)
type Collector struct {
UID string `json:"uid"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
IncludedByDefault bool `json:"includedByDefault"`
Default bool `json:"default"`
Fn CollectorFunc `json:"-"`
// UID is a unique identifier for the collector.
UID string `json:"uid"`
// DisplayName is the name of the collector. User facing.
DisplayName string `json:"displayName"`
// Description is a description of the collector. User facing.
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 {