The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/apps/dashboard/pkg/migration/schemaversion/migrations.go

61 lines
1013 B

package schemaversion
import (
"strconv"
)
const (
MIN_VERSION = 28
LATEST_VERSION = 41
)
type SchemaVersionMigrationFunc func(map[string]interface{}) error
type DataSourceInfo struct {
Default bool
UID string
Name string
Type string
ID int64
APIVersion string
}
type DataSourceInfoProvider interface {
GetDataSourceInfo() []DataSourceInfo
}
func GetMigrations(dsInfoProvider DataSourceInfoProvider) map[int]SchemaVersionMigrationFunc {
return map[int]SchemaVersionMigrationFunc{
29: V29,
30: V30,
31: V31,
32: V32,
33: V33(dsInfoProvider),
34: V34,
35: V35,
36: V36(dsInfoProvider),
37: V37,
38: V38,
39: V39,
40: V40,
41: V41,
}
}
func GetSchemaVersion(dash map[string]interface{}) int {
if v, ok := dash["schemaVersion"]; ok {
switch v := v.(type) {
case int:
return v
case float64:
return int(v)
case string:
if version, err := strconv.Atoi(v); err == nil {
return version
}
return 0
}
}
return 0
}