K8s/Dashboards: Extract Dashboard APIs to an app submodule (#102029)
* Move dashboard k8s APIs to a separate app Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com> * Copy dashboard code in Dockerfile Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com> * Fix conversion generation Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com> * Update OpenAPI snapshot for dashboard/v0alpha1 Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com> --------- Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package schemaversion
|
||||
|
||||
import "strconv"
|
||||
|
||||
type SchemaVersionMigrationFunc func(map[string]interface{}) error
|
||||
|
||||
const LATEST_VERSION = 41
|
||||
|
||||
var Migrations = map[int]SchemaVersionMigrationFunc{
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user