remove datasource from sqlstore (#55288)

This commit is contained in:
ying-jeanne
2022-09-16 06:20:26 -04:00
committed by GitHub
parent 18f33871d1
commit e4741ce8d6
9 changed files with 26 additions and 842 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ func exportDataSources(helper *commitHelper, job *gitExportJob) error {
cmd := &datasources.GetDataSourcesQuery{
OrgId: helper.orgID,
}
err := job.sql.GetDataSources(helper.ctx, cmd)
err := job.datasourceService.GetDataSources(helper.ctx, cmd)
if err != nil {
return nil
}
+4 -1
View File
@@ -14,6 +14,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/playlist"
"github.com/grafana/grafana/pkg/services/sqlstore"
)
@@ -24,6 +25,7 @@ type gitExportJob struct {
logger log.Logger
sql *sqlstore.SQLStore
dashboardsnapshotsService dashboardsnapshots.Service
datasourceService datasources.DataSourceService
playlistService playlist.Service
rootDir string
@@ -36,13 +38,14 @@ type gitExportJob struct {
func startGitExportJob(cfg ExportConfig, sql *sqlstore.SQLStore,
dashboardsnapshotsService dashboardsnapshots.Service, rootDir string, orgID int64,
broadcaster statusBroadcaster, playlistService playlist.Service) (Job, error) {
broadcaster statusBroadcaster, playlistService playlist.Service, datasourceService datasources.DataSourceService) (Job, error) {
job := &gitExportJob{
logger: log.New("git_export_job"),
cfg: cfg,
sql: sql,
dashboardsnapshotsService: dashboardsnapshotsService,
playlistService: playlistService,
datasourceService: datasourceService,
rootDir: rootDir,
broadcaster: broadcaster,
status: ExportStatus{
+5 -2
View File
@@ -13,6 +13,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboardsnapshots"
"github.com/grafana/grafana/pkg/services/datasources"
"github.com/grafana/grafana/pkg/services/featuremgmt"
"github.com/grafana/grafana/pkg/services/live"
"github.com/grafana/grafana/pkg/services/playlist"
@@ -152,13 +153,14 @@ type StandardExport struct {
sql *sqlstore.SQLStore
dashboardsnapshotsService dashboardsnapshots.Service
playlistService playlist.Service
datasourceService datasources.DataSourceService
// updated with mutex
exportJob Job
}
func ProvideService(sql *sqlstore.SQLStore, features featuremgmt.FeatureToggles, gl *live.GrafanaLive, cfg *setting.Cfg,
dashboardsnapshotsService dashboardsnapshots.Service, playlistService playlist.Service) ExportService {
dashboardsnapshotsService dashboardsnapshots.Service, playlistService playlist.Service, datasourceService datasources.DataSourceService) ExportService {
if !features.IsEnabled(featuremgmt.FlagExport) {
return &StubExport{}
}
@@ -169,6 +171,7 @@ func ProvideService(sql *sqlstore.SQLStore, features featuremgmt.FeatureToggles,
logger: log.New("export_service"),
dashboardsnapshotsService: dashboardsnapshotsService,
playlistService: playlistService,
datasourceService: datasourceService,
exportJob: &stoppedJob{},
dataDir: cfg.DataPath,
}
@@ -225,7 +228,7 @@ func (ex *StandardExport) HandleRequestExport(c *models.ReqContext) response.Res
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return response.Error(http.StatusBadRequest, "Error creating export folder", nil)
}
job, err = startGitExportJob(cfg, ex.sql, ex.dashboardsnapshotsService, dir, c.OrgID, broadcast, ex.playlistService)
job, err = startGitExportJob(cfg, ex.sql, ex.dashboardsnapshotsService, dir, c.OrgID, broadcast, ex.playlistService, ex.datasourceService)
default:
return response.Error(http.StatusBadRequest, "Unsupported job format", nil)
}