Add ConfigProvider and modify quota.Service to use it (#109395)
* Add config provider and integrate with wire setup * Refactor quota service to use config provider for configuration management * Enhance OSSConfigProvider to include logging and update ProvideService to return an error. Refactor server initialization to handle potential errors from config provider. Remove unnecessary wire binding for OSSConfigProvider. * Update CODEOWNERS to include the configprovider package under the grafana-backend-services-squad. * Refactor quota service initialization to include context in multiple service providers. Update tests and service implementations to ensure proper context handling during service creation.
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/configprovider"
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
@@ -37,7 +38,9 @@ func TestIntegrationUserDataAccess(t *testing.T) {
|
||||
}
|
||||
|
||||
ss, cfg := db.InitTestDBWithCfg(t)
|
||||
quotaService := quotaimpl.ProvideService(ss, cfg)
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
quotaService := quotaimpl.ProvideService(context.Background(), ss, cfgProvider)
|
||||
orgService, err := orgimpl.ProvideService(ss, cfg, quotaService)
|
||||
require.NoError(t, err)
|
||||
userStore := ProvideStore(ss, setting.NewCfg())
|
||||
@@ -396,7 +399,8 @@ func TestIntegrationUserDataAccess(t *testing.T) {
|
||||
_, err = userStore.GetSignedInUser(context.Background(),
|
||||
&user.GetSignedInUserQuery{
|
||||
OrgID: users[1].OrgID,
|
||||
UserID: userID}) // zero
|
||||
UserID: userID,
|
||||
}) // zero
|
||||
require.Error(t, err)
|
||||
}
|
||||
})
|
||||
@@ -1068,7 +1072,9 @@ func TestIntegrationMetricsUsage(t *testing.T) {
|
||||
}
|
||||
ss, cfg := db.InitTestDBWithCfg(t)
|
||||
userStore := ProvideStore(ss, setting.NewCfg())
|
||||
quotaService := quotaimpl.ProvideService(ss, cfg)
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
quotaService := quotaimpl.ProvideService(context.Background(), ss, cfgProvider)
|
||||
orgService, err := orgimpl.ProvideService(ss, cfg, quotaService)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -1127,7 +1133,9 @@ func assertEqualUser(t *testing.T, expected, got *user.User) {
|
||||
func createOrgAndUserSvc(t *testing.T, store db.DB, cfg *setting.Cfg) (org.Service, user.Service) {
|
||||
t.Helper()
|
||||
|
||||
quotaService := quotaimpl.ProvideService(store, cfg)
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
quotaService := quotaimpl.ProvideService(context.Background(), store, cfgProvider)
|
||||
orgService, err := orgimpl.ProvideService(store, cfg, quotaService)
|
||||
require.NoError(t, err)
|
||||
usrSvc, err := ProvideService(
|
||||
|
||||
Reference in New Issue
Block a user