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:
committed by
GitHub
parent
101aea9647
commit
402572c580
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
"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/plugins"
|
||||
@@ -199,7 +200,9 @@ func createUser(t *testing.T, db db.DB, cfg *setting.Cfg, cmd user.CreateUserCom
|
||||
cfg.AutoAssignOrg = true
|
||||
cfg.AutoAssignOrgId = 1
|
||||
|
||||
quotaService := quotaimpl.ProvideService(db, cfg)
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
quotaService := quotaimpl.ProvideService(context.Background(), db, cfgProvider)
|
||||
orgService, err := orgimpl.ProvideService(db, cfg, quotaService)
|
||||
require.NoError(t, err)
|
||||
usrSvc, err := userimpl.ProvideService(
|
||||
@@ -224,7 +227,7 @@ func makePostRequest(t *testing.T, URL string) (int, map[string]interface{}) {
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var body = make(map[string]interface{})
|
||||
body := make(map[string]interface{})
|
||||
err = json.Unmarshal(b, &body)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -251,7 +254,7 @@ func expectedResp(t *testing.T, filename string) dtos.PluginList {
|
||||
}
|
||||
|
||||
func updateRespSnapshot(t *testing.T, filename string, body string) {
|
||||
err := os.WriteFile(filepath.Join("data", filename), []byte(body), 0600)
|
||||
err := os.WriteFile(filepath.Join("data", filename), []byte(body), 0o600)
|
||||
if err != nil {
|
||||
t.Errorf("error writing snapshot %s: %v", filename, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user