diff --git a/pkg/login/social/social.go b/pkg/login/social/social.go index 5cc6d9f0969..af56b006c4b 100644 --- a/pkg/login/social/social.go +++ b/pkg/login/social/social.go @@ -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 } diff --git a/pkg/server/server.go b/pkg/server/server.go index 321cbeb8e10..c59a37e1c6f 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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 } diff --git a/pkg/server/server_test.go b/pkg/server/server_test.go index 324f772d5ef..be4aca1585e 100644 --- a/pkg/server/server_test.go +++ b/pkg/server/server_test.go @@ -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. diff --git a/pkg/services/supportbundles/interface.go b/pkg/services/supportbundles/interface.go index 66ed4a1e867..e876412087b 100644 --- a/pkg/services/supportbundles/interface.go +++ b/pkg/services/supportbundles/interface.go @@ -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 {