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:
@@ -1,6 +1,7 @@
|
||||
package alerting
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -10,8 +11,7 @@ import (
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"bytes"
|
||||
|
||||
"github.com/grafana/grafana/pkg/configprovider"
|
||||
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/org/orgimpl"
|
||||
@@ -180,7 +180,9 @@ func TestIntegration_NamespacingForRules(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("org separation", func(t *testing.T) {
|
||||
orgService, err := orgimpl.ProvideService(store, cfg, quotaimpl.ProvideService(store, cfg))
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
orgService, err := orgimpl.ProvideService(store, cfg, quotaimpl.ProvideService(context.Background(), store, cfgProvider))
|
||||
require.NoError(t, err)
|
||||
newOrg, err := orgService.CreateWithMember(context.Background(), &org.CreateOrgCommand{Name: "Test Org 2"})
|
||||
require.NoError(t, err)
|
||||
@@ -386,7 +388,9 @@ func TestIntegration_NamespacingForPrometheusRules(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("should maintain org separation for Prometheus rules", func(t *testing.T) {
|
||||
orgService, err := orgimpl.ProvideService(store, cfg, quotaimpl.ProvideService(store, cfg))
|
||||
cfgProvider, err := configprovider.ProvideService(cfg)
|
||||
require.NoError(t, err)
|
||||
orgService, err := orgimpl.ProvideService(store, cfg, quotaimpl.ProvideService(context.Background(), store, cfgProvider))
|
||||
require.NoError(t, err)
|
||||
newOrg, err := orgService.CreateWithMember(context.Background(), &org.CreateOrgCommand{Name: "Prometheus Test Org 2"})
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in New Issue
Block a user