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) {
})
}
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
......@@ -69,7 +62,7 @@ type HTTPServer struct {
AuthTokenService models.UserTokenService `inject:""`
QuotaService *quota.QuotaService `inject:""`
RemoteCacheService *remotecache.RemoteCache `inject:""`
ProvisioningService ProvisioningService `inject:""`
ProvisioningService provisioning.ProvisioningService `inject:""`
Login *login.LoginService `inject:""`
License models.Licensing `inject:""`
BackendPluginManager backendplugin.Manager `inject:""`
......
......@@ -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,
......
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