mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Cleanup: move interface ProvisioningService into provisioning package (#23061)
This commit is contained in:
parent
0870ccea7d
commit
69c5efcf00
@ -987,7 +987,8 @@ func TestDashboardApiEndpoint(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func GetDashboardShouldReturn200WithConfig(sc *scenarioContext, provisioningService ProvisioningService) dtos.DashboardFullWithMeta {
|
||||
func GetDashboardShouldReturn200WithConfig(sc *scenarioContext, provisioningService provisioning.ProvisioningService) dtos.
|
||||
DashboardFullWithMeta {
|
||||
if provisioningService == nil {
|
||||
provisioningService = provisioning.NewProvisioningServiceMock()
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/hooks"
|
||||
"github.com/grafana/grafana/pkg/services/login"
|
||||
"github.com/grafana/grafana/pkg/services/provisioning"
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
"github.com/grafana/grafana/pkg/services/rendering"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
@ -44,14 +45,6 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
type ProvisioningService interface {
|
||||
ProvisionDatasources() error
|
||||
ProvisionNotifications() error
|
||||
ProvisionDashboards() error
|
||||
GetDashboardProvisionerResolvedPath(name string) string
|
||||
GetAllowUiUpdatesFromConfig(name string) bool
|
||||
}
|
||||
|
||||
type HTTPServer struct {
|
||||
log log.Logger
|
||||
macaron *macaron.Macaron
|
||||
@ -59,21 +52,21 @@ type HTTPServer struct {
|
||||
streamManager *live.StreamManager
|
||||
httpSrv *http.Server
|
||||
|
||||
RouteRegister routing.RouteRegister `inject:""`
|
||||
Bus bus.Bus `inject:""`
|
||||
RenderService rendering.Service `inject:""`
|
||||
Cfg *setting.Cfg `inject:""`
|
||||
HooksService *hooks.HooksService `inject:""`
|
||||
CacheService *localcache.CacheService `inject:""`
|
||||
DatasourceCache datasources.CacheService `inject:""`
|
||||
AuthTokenService models.UserTokenService `inject:""`
|
||||
QuotaService *quota.QuotaService `inject:""`
|
||||
RemoteCacheService *remotecache.RemoteCache `inject:""`
|
||||
ProvisioningService ProvisioningService `inject:""`
|
||||
Login *login.LoginService `inject:""`
|
||||
License models.Licensing `inject:""`
|
||||
BackendPluginManager backendplugin.Manager `inject:""`
|
||||
PluginManager *plugins.PluginManager `inject:""`
|
||||
RouteRegister routing.RouteRegister `inject:""`
|
||||
Bus bus.Bus `inject:""`
|
||||
RenderService rendering.Service `inject:""`
|
||||
Cfg *setting.Cfg `inject:""`
|
||||
HooksService *hooks.HooksService `inject:""`
|
||||
CacheService *localcache.CacheService `inject:""`
|
||||
DatasourceCache datasources.CacheService `inject:""`
|
||||
AuthTokenService models.UserTokenService `inject:""`
|
||||
QuotaService *quota.QuotaService `inject:""`
|
||||
RemoteCacheService *remotecache.RemoteCache `inject:""`
|
||||
ProvisioningService provisioning.ProvisioningService `inject:""`
|
||||
Login *login.LoginService `inject:""`
|
||||
License models.Licensing `inject:""`
|
||||
BackendPluginManager backendplugin.Manager `inject:""`
|
||||
PluginManager *plugins.PluginManager `inject:""`
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) Init() error {
|
||||
|
@ -9,6 +9,15 @@ import (
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
)
|
||||
|
||||
type DashboardProvisioner interface {
|
||||
Provision() error
|
||||
PollChanges(ctx context.Context)
|
||||
GetProvisionerResolvedPath(name string) string
|
||||
GetAllowUiUpdatesFromConfig(name string) bool
|
||||
}
|
||||
|
||||
type DashboardProvisionerFactory func(string) (DashboardProvisioner, error)
|
||||
|
||||
type DashboardProvisionerImpl struct {
|
||||
log log.Logger
|
||||
fileReaders []*fileReader
|
||||
|
@ -15,18 +15,17 @@ import (
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type DashboardProvisioner interface {
|
||||
Provision() error
|
||||
PollChanges(ctx context.Context)
|
||||
GetProvisionerResolvedPath(name string) string
|
||||
type ProvisioningService interface {
|
||||
ProvisionDatasources() error
|
||||
ProvisionNotifications() error
|
||||
ProvisionDashboards() error
|
||||
GetDashboardProvisionerResolvedPath(name string) string
|
||||
GetAllowUiUpdatesFromConfig(name string) bool
|
||||
}
|
||||
|
||||
type DashboardProvisionerFactory func(string) (DashboardProvisioner, error)
|
||||
|
||||
func init() {
|
||||
registry.RegisterService(NewProvisioningServiceImpl(
|
||||
func(path string) (DashboardProvisioner, error) {
|
||||
func(path string) (dashboards.DashboardProvisioner, error) {
|
||||
return dashboards.NewDashboardProvisionerImpl(path)
|
||||
},
|
||||
notifiers.Provision,
|
||||
@ -35,7 +34,7 @@ func init() {
|
||||
}
|
||||
|
||||
func NewProvisioningServiceImpl(
|
||||
newDashboardProvisioner DashboardProvisionerFactory,
|
||||
newDashboardProvisioner dashboards.DashboardProvisionerFactory,
|
||||
provisionNotifiers func(string) error,
|
||||
provisionDatasources func(string) error,
|
||||
) *provisioningServiceImpl {
|
||||
@ -51,8 +50,8 @@ type provisioningServiceImpl struct {
|
||||
Cfg *setting.Cfg `inject:""`
|
||||
log log.Logger
|
||||
pollingCtxCancel context.CancelFunc
|
||||
newDashboardProvisioner DashboardProvisionerFactory
|
||||
dashboardProvisioner DashboardProvisioner
|
||||
newDashboardProvisioner dashboards.DashboardProvisionerFactory
|
||||
dashboardProvisioner dashboards.DashboardProvisioner
|
||||
provisionNotifiers func(string) error
|
||||
provisionDatasources func(string) error
|
||||
mutex sync.Mutex
|
||||
|
@ -92,7 +92,7 @@ func setup() *serviceTestStruct {
|
||||
}
|
||||
|
||||
serviceTest.service = NewProvisioningServiceImpl(
|
||||
func(path string) (DashboardProvisioner, error) {
|
||||
func(path string) (dashboards.DashboardProvisioner, error) {
|
||||
return serviceTest.mock, nil
|
||||
},
|
||||
nil,
|
||||
|
Loading…
Reference in New Issue
Block a user