feat: provides MT Dashboard service (#110447)

This commit is contained in:
Costa Alexoglou
2025-09-03 20:41:37 +00:00
committed by GitHub
parent 7d32640179
commit 3d2cef5f07
43 changed files with 284 additions and 69 deletions
+5 -4
View File
@@ -1,6 +1,7 @@
package migration
import (
"context"
"fmt"
"sync"
@@ -14,8 +15,8 @@ func Initialize(dsInfoProvider schemaversion.DataSourceInfoProvider, panelProvid
// Migrate migrates the given dashboard to the target version.
// This will block until the migrator is initialized.
func Migrate(dash map[string]interface{}, targetVersion int) error {
return migratorInstance.migrate(dash, targetVersion)
func Migrate(ctx context.Context, dash map[string]interface{}, targetVersion int) error {
return migratorInstance.migrate(ctx, dash, targetVersion)
}
var (
@@ -38,7 +39,7 @@ func (m *migrator) init(dsInfoProvider schemaversion.DataSourceInfoProvider, pan
})
}
func (m *migrator) migrate(dash map[string]interface{}, targetVersion int) error {
func (m *migrator) migrate(ctx context.Context, dash map[string]interface{}, targetVersion int) error {
if dash == nil {
return schemaversion.NewMigrationError("dashboard is nil", 0, targetVersion, "")
}
@@ -57,7 +58,7 @@ func (m *migrator) migrate(dash map[string]interface{}, targetVersion int) error
for nextVersion := inputVersion + 1; nextVersion <= targetVersion; nextVersion++ {
if migration, ok := m.migrations[nextVersion]; ok {
if err := migration(dash); err != nil {
if err := migration(ctx, dash); err != nil {
functionName := fmt.Sprintf("V%d", nextVersion)
return schemaversion.NewMigrationError("migration failed: "+err.Error(), inputVersion, nextVersion, functionName)
}