Dashboards: Cover the Switch variable in schema transformations - part 2. (#114549)

* feat: add v2alpha_1 conversion for the switch variable

* chore: gofmt fixes

* chore: update comments in tests

* chore: fix gofmt

* Update specs

* tests: update the v2alpha1 openapi snapshot

---------

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
Levente Balogh
2025-11-28 14:21:33 +01:00
committed by GitHub
co-authored by Ivan Ortega
parent c75137b2d3
commit 930f7ce489
16 changed files with 809 additions and 148 deletions
@@ -3100,7 +3100,7 @@
}
}
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind": {
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKindOrSwitchVariableKind": {
"type": "object",
"properties": {
"AdhocVariableKind": {
@@ -3124,6 +3124,9 @@
"QueryVariableKind": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardQueryVariableKind"
},
"SwitchVariableKind": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardSwitchVariableKind"
},
"TextVariableKind": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardTextVariableKind"
}
@@ -3520,7 +3523,7 @@
"description": "Configured template variables.",
"type": "array",
"items": {
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKind"
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardQueryVariableKindOrTextVariableKindOrConstantVariableKindOrDatasourceVariableKindOrIntervalVariableKindOrCustomVariableKindOrGroupByVariableKindOrAdhocVariableKindOrSwitchVariableKind"
}
}
}
@@ -3587,6 +3590,71 @@
}
}
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardSwitchVariableKind": {
"type": "object",
"required": [
"kind",
"spec"
],
"properties": {
"kind": {
"type": "string",
"default": ""
},
"spec": {
"default": {},
"allOf": [
{
"$ref": "#/components/schemas/com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardSwitchVariableSpec"
}
]
}
}
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardSwitchVariableSpec": {
"description": "Switch variable specification",
"type": "object",
"required": [
"name",
"current",
"enabledValue",
"disabledValue",
"hide",
"skipUrlSync"
],
"properties": {
"current": {
"type": "string",
"default": ""
},
"description": {
"type": "string"
},
"disabledValue": {
"type": "string",
"default": ""
},
"enabledValue": {
"type": "string",
"default": ""
},
"hide": {
"type": "string",
"default": ""
},
"label": {
"type": "string"
},
"name": {
"type": "string",
"default": ""
},
"skipUrlSync": {
"type": "boolean",
"default": false
}
}
},
"com.github.grafana.grafana.apps.dashboard.pkg.apis.dashboard.v2alpha1.DashboardTabRepeatOptions": {
"type": "object",
"required": [