abdf1943b9
* Dashboard Migrations: V31 LabelsToFields-Merge Migration * Dashboard Migrations: V32 No-op migration * simplify * Refactor to reduce nesting * Dashboard Migrations: V30 value mappings and tooltip options * Do not automigrate since graph is migrated in v27 * Refactor to reduce nesting * Add test case for invalid mapping * migrate to v29 * wip * Fix tests * fix output * wip * fix min version issue * fix wire * ignore gauge logic as it never get's executed * add panel migration to test * improvements * update * cleanup * address mappings inconsistencies * cleanup * fix lint issues * add cfg when initializing * v27 migration * migrate to v26 * preallocate array * remove logic for grafana-singlestat because it's shared with stat logic; improve error handling and testing * fix go lint * don't preallocate; cleanup comments * cleanup * wip * run internal provider function when getting a single panel * clean up; add tests * add tests for panel plugin service * remove obsolete mock for getting panel plugin * add tests for the whole pipeline * fix test and lint * migrate to v23 * migrate to v22 * refactor * fix test --------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
67 lines
1.4 KiB
Go
67 lines
1.4 KiB
Go
package schemaversion
|
|
|
|
// V22 migrates table panel styles to set align property to 'auto'.
|
|
// This migration ensures that all table panel styles have their align property
|
|
// set to 'auto' for consistent alignment behavior.
|
|
//
|
|
// Example before migration:
|
|
//
|
|
// "panels": [
|
|
// {
|
|
// "type": "table",
|
|
// "styles": [
|
|
// { "type": "number", "pattern": "Time", "align": "left" },
|
|
// { "type": "string", "pattern": "Value", "align": "right" }
|
|
// ]
|
|
// }
|
|
// ]
|
|
//
|
|
// Example after migration:
|
|
//
|
|
// "panels": [
|
|
// {
|
|
// "type": "table",
|
|
// "styles": [
|
|
// { "type": "number", "pattern": "Time", "align": "auto" },
|
|
// { "type": "string", "pattern": "Value", "align": "auto" }
|
|
// ]
|
|
// }
|
|
// ]
|
|
func V22(dashboard map[string]interface{}) error {
|
|
dashboard["schemaVersion"] = 22
|
|
|
|
panels, ok := dashboard["panels"].([]interface{})
|
|
if !ok {
|
|
return nil
|
|
}
|
|
|
|
for _, p := range panels {
|
|
panel, ok := p.(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
// Only process table panels
|
|
panelType, ok := panel["type"].(string)
|
|
if !ok || panelType != "table" {
|
|
continue
|
|
}
|
|
|
|
styles, ok := panel["styles"].([]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
|
|
// Update each style to set align to 'auto'
|
|
for _, s := range styles {
|
|
style, ok := s.(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
style["align"] = "auto"
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|