Commit 69c5efcf by huanggze Committed by GitHub

Cleanup: move interface ProvisioningService into provisioning package (#23061)

parent 0870ccea
...@@ -987,7 +987,8 @@ func TestDashboardApiEndpoint(t *testing.T) { ...@@ -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 { if provisioningService == nil {
provisioningService = provisioning.NewProvisioningServiceMock() provisioningService = provisioning.NewProvisioningServiceMock()
} }
......
...@@ -27,6 +27,7 @@ import ( ...@@ -27,6 +27,7 @@ import (
"github.com/grafana/grafana/pkg/services/datasources" "github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/hooks" "github.com/grafana/grafana/pkg/services/hooks"
"github.com/grafana/grafana/pkg/services/login" "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/quota"
"github.com/grafana/grafana/pkg/services/rendering" "github.com/grafana/grafana/pkg/services/rendering"
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
...@@ -44,14 +45,6 @@ func init() { ...@@ -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 { type HTTPServer struct {
log log.Logger log log.Logger
macaron *macaron.Macaron macaron *macaron.Macaron
...@@ -59,21 +52,21 @@ type HTTPServer struct { ...@@ -59,21 +52,21 @@ type HTTPServer struct {
streamManager *live.StreamManager streamManager *live.StreamManager
httpSrv *http.Server httpSrv *http.Server
RouteRegister routing.RouteRegister `inject:""` RouteRegister routing.RouteRegister `inject:""`
Bus bus.Bus `inject:""` Bus bus.Bus `inject:""`
RenderService rendering.Service `inject:""` RenderService rendering.Service `inject:""`
Cfg *setting.Cfg `inject:""` Cfg *setting.Cfg `inject:""`
HooksService *hooks.HooksService `inject:""` HooksService *hooks.HooksService `inject:""`
CacheService *localcache.CacheService `inject:""` CacheService *localcache.CacheService `inject:""`
DatasourceCache datasources.CacheService `inject:""` DatasourceCache datasources.CacheService `inject:""`
AuthTokenService models.UserTokenService `inject:""` AuthTokenService models.UserTokenService `inject:""`
QuotaService *quota.QuotaService `inject:""` QuotaService *quota.QuotaService `inject:""`
RemoteCacheService *remotecache.RemoteCache `inject:""` RemoteCacheService *remotecache.RemoteCache `inject:""`
ProvisioningService ProvisioningService `inject:""` ProvisioningService provisioning.ProvisioningService `inject:""`
Login *login.LoginService `inject:""` Login *login.LoginService `inject:""`
License models.Licensing `inject:""` License models.Licensing `inject:""`
BackendPluginManager backendplugin.Manager `inject:""` BackendPluginManager backendplugin.Manager `inject:""`
PluginManager *plugins.PluginManager `inject:""` PluginManager *plugins.PluginManager `inject:""`
} }
func (hs *HTTPServer) Init() error { func (hs *HTTPServer) Init() error {
......
...@@ -9,6 +9,15 @@ import ( ...@@ -9,6 +9,15 @@ import (
"github.com/grafana/grafana/pkg/util/errutil" "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 { type DashboardProvisionerImpl struct {
log log.Logger log log.Logger
fileReaders []*fileReader fileReaders []*fileReader
......
...@@ -15,18 +15,17 @@ import ( ...@@ -15,18 +15,17 @@ import (
"github.com/grafana/grafana/pkg/setting" "github.com/grafana/grafana/pkg/setting"
) )
type DashboardProvisioner interface { type ProvisioningService interface {
Provision() error ProvisionDatasources() error
PollChanges(ctx context.Context) ProvisionNotifications() error
GetProvisionerResolvedPath(name string) string ProvisionDashboards() error
GetDashboardProvisionerResolvedPath(name string) string
GetAllowUiUpdatesFromConfig(name string) bool GetAllowUiUpdatesFromConfig(name string) bool
} }
type DashboardProvisionerFactory func(string) (DashboardProvisioner, error)
func init() { func init() {
registry.RegisterService(NewProvisioningServiceImpl( registry.RegisterService(NewProvisioningServiceImpl(
func(path string) (DashboardProvisioner, error) { func(path string) (dashboards.DashboardProvisioner, error) {
return dashboards.NewDashboardProvisionerImpl(path) return dashboards.NewDashboardProvisionerImpl(path)
}, },
notifiers.Provision, notifiers.Provision,
...@@ -35,7 +34,7 @@ func init() { ...@@ -35,7 +34,7 @@ func init() {
} }
func NewProvisioningServiceImpl( func NewProvisioningServiceImpl(
newDashboardProvisioner DashboardProvisionerFactory, newDashboardProvisioner dashboards.DashboardProvisionerFactory,
provisionNotifiers func(string) error, provisionNotifiers func(string) error,
provisionDatasources func(string) error, provisionDatasources func(string) error,
) *provisioningServiceImpl { ) *provisioningServiceImpl {
...@@ -51,8 +50,8 @@ type provisioningServiceImpl struct { ...@@ -51,8 +50,8 @@ type provisioningServiceImpl struct {
Cfg *setting.Cfg `inject:""` Cfg *setting.Cfg `inject:""`
log log.Logger log log.Logger
pollingCtxCancel context.CancelFunc pollingCtxCancel context.CancelFunc
newDashboardProvisioner DashboardProvisionerFactory newDashboardProvisioner dashboards.DashboardProvisionerFactory
dashboardProvisioner DashboardProvisioner dashboardProvisioner dashboards.DashboardProvisioner
provisionNotifiers func(string) error provisionNotifiers func(string) error
provisionDatasources func(string) error provisionDatasources func(string) error
mutex sync.Mutex mutex sync.Mutex
......
...@@ -92,7 +92,7 @@ func setup() *serviceTestStruct { ...@@ -92,7 +92,7 @@ func setup() *serviceTestStruct {
} }
serviceTest.service = NewProvisioningServiceImpl( serviceTest.service = NewProvisioningServiceImpl(
func(path string) (DashboardProvisioner, error) { func(path string) (dashboards.DashboardProvisioner, error) {
return serviceTest.mock, nil return serviceTest.mock, nil
}, },
nil, nil,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment