Revert "v1 to v2 conversion: Fix issue when Grafana datasource wouldn't be resolved correctly (#114555) (#114725)
Revert "v1 to v2 conversion: Fix issue when Grafana datasource wouldn't be resolved correctly (#114555)"
This reverts commit ac62070ac7.
This commit is contained in:
apps/dashboard/pkg/migration/conversion/testdata/input/v1beta1.panel-datasource-type-datasource.json
Vendored
-234
@@ -1,234 +0,0 @@
|
||||
{
|
||||
"kind": "DashboardWithAccessInfo",
|
||||
"apiVersion": "dashboard.grafana.app/v1beta1",
|
||||
"metadata": {
|
||||
"name": "ad6phhg",
|
||||
"namespace": "default",
|
||||
"uid": "spsmxIXYXdgxtY972XX7j3dj3ijM3IZXDmsCfjygSP8X",
|
||||
"resourceVersion": "2",
|
||||
"generation": 2,
|
||||
"creationTimestamp": "2025-11-27T12:31:46Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "283"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedTimestamp": "2025-11-27T12:32:09Z"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": {
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"mappings": [],
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "red",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 50
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "percent"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 15,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": false
|
||||
},
|
||||
"maxVizHeight": 300,
|
||||
"minVizHeight": 16,
|
||||
"minVizWidth": 8,
|
||||
"namePlacement": "auto",
|
||||
"orientation": "horizontal",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true,
|
||||
"sizing": "auto",
|
||||
"valueMode": "color"
|
||||
},
|
||||
"pluginVersion": "12.4.0-pre",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "B",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "C",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "D",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "E",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "F",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "G",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"labels": "",
|
||||
"refId": "H",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "I",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "J",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "K",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "L",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "M",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "N",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"labels": "",
|
||||
"refId": "O",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "P",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "Q",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
],
|
||||
"title": "Panel Title",
|
||||
"type": "bargauge"
|
||||
}
|
||||
],
|
||||
"preload": false,
|
||||
"refresh": "",
|
||||
"schemaVersion": 42,
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Bar Gauge Demo Unfilled Copy v1",
|
||||
"weekStart": ""
|
||||
},
|
||||
"status": {},
|
||||
"access": {
|
||||
"slug": "bar-gauge-demo-unfilled-copy-v1",
|
||||
"url": "/d/ad6phhg/bar-gauge-demo-unfilled-copy-v1",
|
||||
"isPublic": false,
|
||||
"canSave": true,
|
||||
"canEdit": true,
|
||||
"canAdmin": true,
|
||||
"canStar": true,
|
||||
"canDelete": true,
|
||||
"annotationsPermissions": {
|
||||
"dashboard": {
|
||||
"canAdd": true,
|
||||
"canEdit": true,
|
||||
"canDelete": true
|
||||
},
|
||||
"organization": {
|
||||
"canAdd": true,
|
||||
"canEdit": true,
|
||||
"canDelete": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-217
@@ -1,217 +0,0 @@
|
||||
{
|
||||
"kind": "DashboardWithAccessInfo",
|
||||
"apiVersion": "dashboard.grafana.app/v0alpha1",
|
||||
"metadata": {
|
||||
"name": "ad6phhg",
|
||||
"namespace": "default",
|
||||
"uid": "spsmxIXYXdgxtY972XX7j3dj3ijM3IZXDmsCfjygSP8X",
|
||||
"resourceVersion": "2",
|
||||
"generation": 2,
|
||||
"creationTimestamp": "2025-11-27T12:31:46Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "283"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedTimestamp": "2025-11-27T12:32:09Z"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": {
|
||||
"list": [
|
||||
{
|
||||
"builtIn": 1,
|
||||
"datasource": {
|
||||
"uid": "-- Grafana --"
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts",
|
||||
"type": "dashboard"
|
||||
}
|
||||
]
|
||||
},
|
||||
"editable": true,
|
||||
"fiscalYearStartMonth": 0,
|
||||
"graphTooltip": 0,
|
||||
"links": [],
|
||||
"panels": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "datasource"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"mappings": [],
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "red",
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": 50
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "percent"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 15,
|
||||
"w": 24,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"id": 4,
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": false
|
||||
},
|
||||
"maxVizHeight": 300,
|
||||
"minVizHeight": 16,
|
||||
"minVizWidth": 8,
|
||||
"namePlacement": "auto",
|
||||
"orientation": "horizontal",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true,
|
||||
"sizing": "auto",
|
||||
"valueMode": "color"
|
||||
},
|
||||
"pluginVersion": "12.4.0-pre",
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "B",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "C",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "D",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "E",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "F",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "G",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"labels": "",
|
||||
"refId": "H",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "I",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "J",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "K",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "L",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "M",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "N",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"labels": "",
|
||||
"refId": "O",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "P",
|
||||
"scenarioId": "random_walk"
|
||||
},
|
||||
{
|
||||
"datasource": {},
|
||||
"refId": "Q",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
],
|
||||
"title": "Panel Title",
|
||||
"type": "bargauge"
|
||||
}
|
||||
],
|
||||
"preload": false,
|
||||
"refresh": "",
|
||||
"schemaVersion": 42,
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {},
|
||||
"timezone": "",
|
||||
"title": "Bar Gauge Demo Unfilled Copy v1",
|
||||
"weekStart": ""
|
||||
},
|
||||
"status": {
|
||||
"conversion": {
|
||||
"failed": false,
|
||||
"storedVersion": "v1beta1"
|
||||
}
|
||||
}
|
||||
}
|
||||
-455
@@ -1,455 +0,0 @@
|
||||
{
|
||||
"kind": "DashboardWithAccessInfo",
|
||||
"apiVersion": "dashboard.grafana.app/v2alpha1",
|
||||
"metadata": {
|
||||
"name": "ad6phhg",
|
||||
"namespace": "default",
|
||||
"uid": "spsmxIXYXdgxtY972XX7j3dj3ijM3IZXDmsCfjygSP8X",
|
||||
"resourceVersion": "2",
|
||||
"generation": 2,
|
||||
"creationTimestamp": "2025-11-27T12:31:46Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "283"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedTimestamp": "2025-11-27T12:32:09Z"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "",
|
||||
"spec": {}
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts",
|
||||
"builtIn": true,
|
||||
"legacyOptions": {
|
||||
"type": "dashboard"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Off",
|
||||
"editable": true,
|
||||
"elements": {
|
||||
"panel-4": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"id": 4,
|
||||
"title": "Panel Title",
|
||||
"description": "",
|
||||
"links": [],
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "A",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "B",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "C",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "D",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "E",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "F",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "G",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"labels": "",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "H",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "I",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "J",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "K",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "L",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "M",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "N",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"labels": "",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "O",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "P",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "datasource",
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"datasource": {
|
||||
"type": "datasource",
|
||||
"uid": "grafana"
|
||||
},
|
||||
"refId": "Q",
|
||||
"hidden": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"transformations": [],
|
||||
"queryOptions": {}
|
||||
}
|
||||
},
|
||||
"vizConfig": {
|
||||
"kind": "bargauge",
|
||||
"spec": {
|
||||
"pluginVersion": "12.4.0-pre",
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": false
|
||||
},
|
||||
"maxVizHeight": 300,
|
||||
"minVizHeight": 16,
|
||||
"minVizWidth": 8,
|
||||
"namePlacement": "auto",
|
||||
"orientation": "horizontal",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true,
|
||||
"sizing": "auto",
|
||||
"valueMode": "color"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percent",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"value": 0,
|
||||
"color": "red"
|
||||
},
|
||||
{
|
||||
"value": 50,
|
||||
"color": "yellow"
|
||||
}
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "GridLayout",
|
||||
"spec": {
|
||||
"items": [
|
||||
{
|
||||
"kind": "GridLayoutItem",
|
||||
"spec": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 24,
|
||||
"height": 15,
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-4"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"preload": false,
|
||||
"tags": [],
|
||||
"timeSettings": {
|
||||
"timezone": "",
|
||||
"from": "now-6h",
|
||||
"to": "now",
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"hideTimepicker": false,
|
||||
"fiscalYearStartMonth": 0
|
||||
},
|
||||
"title": "Bar Gauge Demo Unfilled Copy v1",
|
||||
"variables": []
|
||||
},
|
||||
"status": {}
|
||||
}
|
||||
-475
@@ -1,475 +0,0 @@
|
||||
{
|
||||
"kind": "DashboardWithAccessInfo",
|
||||
"apiVersion": "dashboard.grafana.app/v2beta1",
|
||||
"metadata": {
|
||||
"name": "ad6phhg",
|
||||
"namespace": "default",
|
||||
"uid": "spsmxIXYXdgxtY972XX7j3dj3ijM3IZXDmsCfjygSP8X",
|
||||
"resourceVersion": "2",
|
||||
"generation": 2,
|
||||
"creationTimestamp": "2025-11-27T12:31:46Z",
|
||||
"labels": {
|
||||
"grafana.app/deprecatedInternalID": "283"
|
||||
},
|
||||
"annotations": {
|
||||
"grafana.app/createdBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedBy": "user:eex2ofwuj0agwd",
|
||||
"grafana.app/updatedTimestamp": "2025-11-27T12:32:09Z"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"annotations": [
|
||||
{
|
||||
"kind": "AnnotationQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "",
|
||||
"version": "v0",
|
||||
"spec": {}
|
||||
},
|
||||
"enable": true,
|
||||
"hide": true,
|
||||
"iconColor": "rgba(0, 211, 255, 1)",
|
||||
"name": "Annotations \u0026 Alerts",
|
||||
"builtIn": true,
|
||||
"legacyOptions": {
|
||||
"type": "dashboard"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"cursorSync": "Off",
|
||||
"editable": true,
|
||||
"elements": {
|
||||
"panel-4": {
|
||||
"kind": "Panel",
|
||||
"spec": {
|
||||
"id": 4,
|
||||
"title": "Panel Title",
|
||||
"description": "",
|
||||
"links": [],
|
||||
"data": {
|
||||
"kind": "QueryGroup",
|
||||
"spec": {
|
||||
"queries": [
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "A",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "B",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "C",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "D",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "E",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "F",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "G",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"labels": "",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "H",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "I",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "J",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "K",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "L",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "M",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "N",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"labels": "",
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "O",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "P",
|
||||
"hidden": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "PanelQuery",
|
||||
"spec": {
|
||||
"query": {
|
||||
"kind": "DataQuery",
|
||||
"group": "datasource",
|
||||
"version": "v0",
|
||||
"datasource": {
|
||||
"name": "grafana"
|
||||
},
|
||||
"spec": {
|
||||
"scenarioId": "random_walk"
|
||||
}
|
||||
},
|
||||
"refId": "Q",
|
||||
"hidden": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"transformations": [],
|
||||
"queryOptions": {}
|
||||
}
|
||||
},
|
||||
"vizConfig": {
|
||||
"kind": "VizConfig",
|
||||
"group": "bargauge",
|
||||
"version": "12.4.0-pre",
|
||||
"spec": {
|
||||
"options": {
|
||||
"displayMode": "gradient",
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom",
|
||||
"showLegend": false
|
||||
},
|
||||
"maxVizHeight": 300,
|
||||
"minVizHeight": 16,
|
||||
"minVizWidth": 8,
|
||||
"namePlacement": "auto",
|
||||
"orientation": "horizontal",
|
||||
"reduceOptions": {
|
||||
"calcs": [
|
||||
"mean"
|
||||
],
|
||||
"fields": "",
|
||||
"values": false
|
||||
},
|
||||
"showUnfilled": true,
|
||||
"sizing": "auto",
|
||||
"valueMode": "color"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percent",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"value": 0,
|
||||
"color": "red"
|
||||
},
|
||||
{
|
||||
"value": 50,
|
||||
"color": "yellow"
|
||||
}
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
}
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"layout": {
|
||||
"kind": "GridLayout",
|
||||
"spec": {
|
||||
"items": [
|
||||
{
|
||||
"kind": "GridLayoutItem",
|
||||
"spec": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 24,
|
||||
"height": 15,
|
||||
"element": {
|
||||
"kind": "ElementReference",
|
||||
"name": "panel-4"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"links": [],
|
||||
"liveNow": false,
|
||||
"preload": false,
|
||||
"tags": [],
|
||||
"timeSettings": {
|
||||
"timezone": "",
|
||||
"from": "now-6h",
|
||||
"to": "now",
|
||||
"autoRefresh": "",
|
||||
"autoRefreshIntervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"hideTimepicker": false,
|
||||
"fiscalYearStartMonth": 0
|
||||
},
|
||||
"title": "Bar Gauge Demo Unfilled Copy v1",
|
||||
"variables": []
|
||||
},
|
||||
"status": {}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
schemaversion "github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||
)
|
||||
|
||||
// getDefaultDatasourceType gets the default datasource type using the datasource provider
|
||||
@@ -53,16 +52,6 @@ func getDatasourceTypeByUID(ctx context.Context, uid string, provider schemavers
|
||||
return getDefaultDatasourceType(ctx, provider)
|
||||
}
|
||||
|
||||
// resolveGrafanaDatasourceUID resolves the Grafana datasource UID when type is "datasource" and UID is empty.
|
||||
// The Grafana datasource has type "datasource" and UID "grafana". When a v1beta1 dashboard has
|
||||
// datasource: { type: "datasource" } with no UID, it should resolve to uid: "grafana".
|
||||
func resolveGrafanaDatasourceUID(dsType, dsUID string) string {
|
||||
if dsType == "datasource" && dsUID == "" {
|
||||
return grafanads.DatasourceUID
|
||||
}
|
||||
return dsUID
|
||||
}
|
||||
|
||||
// prepareV1beta1ConversionContext sets up the context with namespace and service identity
|
||||
// for v1beta1 dashboard conversions. This context is needed to retrieve datasources for
|
||||
// converting dashboard datasource references.
|
||||
@@ -1685,9 +1674,6 @@ func buildGroupByVariable(ctx context.Context, varMap map[string]interface{}, co
|
||||
// If no UID and no type, use default
|
||||
datasourceType = getDefaultDatasourceType(ctx, dsIndexProvider)
|
||||
}
|
||||
|
||||
// Resolve Grafana datasource UID when type is "datasource" and UID is empty
|
||||
datasourceUID = resolveGrafanaDatasourceUID(datasourceType, datasourceUID)
|
||||
} else {
|
||||
datasourceType = getDefaultDatasourceType(ctx, dsIndexProvider)
|
||||
}
|
||||
@@ -1890,45 +1876,22 @@ func transformPanelQueries(ctx context.Context, panelMap map[string]interface{},
|
||||
|
||||
// Get panel datasource
|
||||
var panelDatasource *dashv2alpha1.DashboardDataSourceRef
|
||||
ds, dsExists := panelMap["datasource"]
|
||||
if ds, ok := panelMap["datasource"].(map[string]interface{}); ok {
|
||||
dsUID := schemaversion.GetStringValue(ds, "uid")
|
||||
dsType := schemaversion.GetStringValue(ds, "type")
|
||||
|
||||
if dsExists && ds != nil {
|
||||
if dsMap, ok := ds.(map[string]interface{}); ok {
|
||||
// Handle panel datasource as object
|
||||
dsUID := schemaversion.GetStringValue(dsMap, "uid")
|
||||
dsType := schemaversion.GetStringValue(dsMap, "type")
|
||||
// If we have a UID, use it to get the correct type from the datasource service
|
||||
// BUT: Don't try to resolve types for template variables
|
||||
if dsUID != "" && dsType == "" && !isTemplateVariable(dsUID) {
|
||||
dsType = getDatasourceTypeByUID(ctx, dsUID, dsIndexProvider)
|
||||
} else if dsUID == "" && dsType == "" {
|
||||
// If no UID and no type, use default
|
||||
dsType = getDefaultDatasourceType(ctx, dsIndexProvider)
|
||||
}
|
||||
|
||||
// Check if datasource object is effectively empty (no uid and no type)
|
||||
// Empty objects {} should be preserved as empty, not converted to defaults
|
||||
isEmpty := dsUID == "" && dsType == ""
|
||||
|
||||
// If we have a UID, use it to get the correct type from the datasource service
|
||||
// BUT: Don't try to resolve types for template variables
|
||||
if dsUID != "" && dsType == "" && !isTemplateVariable(dsUID) {
|
||||
dsType = getDatasourceTypeByUID(ctx, dsUID, dsIndexProvider)
|
||||
} else if !isEmpty && dsUID == "" && dsType == "" {
|
||||
// Only set default if datasource is missing (not empty object)
|
||||
// Empty objects {} should remain empty
|
||||
dsType = getDefaultDatasourceType(ctx, dsIndexProvider)
|
||||
}
|
||||
|
||||
// Resolve Grafana datasource UID when type is "datasource" and UID is empty
|
||||
// Only resolve if we have a type (not for empty objects)
|
||||
if !isEmpty {
|
||||
dsUID = resolveGrafanaDatasourceUID(dsType, dsUID)
|
||||
}
|
||||
|
||||
// Only create panelDatasource if it's not empty after resolution
|
||||
// Empty objects {} should result in nil panelDatasource
|
||||
// After resolution, check if we have a type or UID (not just the original isEmpty)
|
||||
// This ensures that type: "datasource" with empty UID gets resolved to uid: "grafana"
|
||||
// and panelDatasource is created
|
||||
if dsType != "" || dsUID != "" {
|
||||
panelDatasource = &dashv2alpha1.DashboardDataSourceRef{
|
||||
Type: &dsType,
|
||||
Uid: &dsUID,
|
||||
}
|
||||
}
|
||||
panelDatasource = &dashv2alpha1.DashboardDataSourceRef{
|
||||
Type: &dsType,
|
||||
Uid: &dsUID,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1955,24 +1918,12 @@ func transformSingleQuery(ctx context.Context, targetMap map[string]interface{},
|
||||
queryDatasourceUID = schemaversion.GetStringValue(ds, "uid")
|
||||
queryDatasourceType = schemaversion.GetStringValue(ds, "type")
|
||||
|
||||
// If target datasource is empty object {} (no uid and no type), treat it as missing
|
||||
// and fall through to use panel datasource (matches frontend behavior in v36 migration)
|
||||
if queryDatasourceUID == "" && queryDatasourceType == "" {
|
||||
// Empty datasource object - will use panel datasource below
|
||||
} else {
|
||||
// If we have a UID, use it to get the correct type from the datasource service
|
||||
// BUT: Don't try to resolve types for template variables
|
||||
if queryDatasourceUID != "" && queryDatasourceType == "" && !isTemplateVariable(queryDatasourceUID) {
|
||||
queryDatasourceType = getDatasourceTypeByUID(ctx, queryDatasourceUID, dsIndexProvider)
|
||||
}
|
||||
|
||||
// Resolve Grafana datasource UID when type is "datasource" and UID is empty
|
||||
queryDatasourceUID = resolveGrafanaDatasourceUID(queryDatasourceType, queryDatasourceUID)
|
||||
// If we have a UID, use it to get the correct type from the datasource service
|
||||
// BUT: Don't try to resolve types for template variables
|
||||
if queryDatasourceUID != "" && queryDatasourceType == "" && !isTemplateVariable(queryDatasourceUID) {
|
||||
queryDatasourceType = getDatasourceTypeByUID(ctx, queryDatasourceUID, dsIndexProvider)
|
||||
}
|
||||
}
|
||||
|
||||
// Use panel datasource if target datasource is missing or empty
|
||||
if queryDatasourceUID == "" && queryDatasourceType == "" && panelDatasource != nil {
|
||||
} else if panelDatasource != nil {
|
||||
// Only use panel datasource if it's not a mixed datasource
|
||||
// Mixed datasources should not be propagated to individual queries
|
||||
if panelDatasource.Uid != nil && *panelDatasource.Uid != "-- Mixed --" {
|
||||
@@ -1980,10 +1931,6 @@ func transformSingleQuery(ctx context.Context, targetMap map[string]interface{},
|
||||
queryDatasourceType = *panelDatasource.Type
|
||||
}
|
||||
queryDatasourceUID = *panelDatasource.Uid
|
||||
} else if panelDatasource.Type != nil && *panelDatasource.Type == "datasource" {
|
||||
// Handle case where panel datasource has type "datasource" but no UID
|
||||
queryDatasourceType = *panelDatasource.Type
|
||||
queryDatasourceUID = resolveGrafanaDatasourceUID(*panelDatasource.Type, "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
||||
dashv1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v1beta1"
|
||||
dashv2alpha1 "github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v2alpha1"
|
||||
"github.com/grafana/grafana/apps/dashboard/pkg/migration"
|
||||
migrationtestutil "github.com/grafana/grafana/apps/dashboard/pkg/migration/testutil"
|
||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||
)
|
||||
|
||||
// TestV1beta1ToV2alpha1 tests conversion from v1beta1 to v2alpha1 with various datasource scenarios
|
||||
func TestV1beta1ToV2alpha1(t *testing.T) {
|
||||
// Initialize the migrator with test providers
|
||||
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
|
||||
leProvider := migrationtestutil.NewLibraryElementProvider()
|
||||
migration.Initialize(dsProvider, leProvider)
|
||||
|
||||
// Set up conversion scheme
|
||||
scheme := runtime.NewScheme()
|
||||
err := RegisterConversions(scheme, dsProvider, leProvider)
|
||||
require.NoError(t, err)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
createV1beta1 func() *dashv1.Dashboard
|
||||
validateV2alpha1 func(t *testing.T, v2alpha1 *dashv2alpha1.Dashboard)
|
||||
}{
|
||||
{
|
||||
name: "panel datasource type datasource with no UID - resolves to grafana UID",
|
||||
createV1beta1: func() *dashv1.Dashboard {
|
||||
return &dashv1.Dashboard{
|
||||
Spec: dashv1.DashboardSpec{
|
||||
Object: map[string]interface{}{
|
||||
"title": "Test Dashboard",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 1,
|
||||
"type": "bargauge",
|
||||
// Panel datasource has type: "datasource" but no UID
|
||||
"datasource": map[string]interface{}{
|
||||
"type": "datasource",
|
||||
// No "uid" field
|
||||
},
|
||||
"targets": []interface{}{
|
||||
map[string]interface{}{
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk",
|
||||
// Target datasource is empty object {}
|
||||
"datasource": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validateV2alpha1: func(t *testing.T, v2alpha1 *dashv2alpha1.Dashboard) {
|
||||
require.NotNil(t, v2alpha1.Spec.Elements["panel-1"])
|
||||
panel := v2alpha1.Spec.Elements["panel-1"].PanelKind
|
||||
require.NotNil(t, panel)
|
||||
|
||||
// Verify queries have datasource with UID resolved to "grafana"
|
||||
require.Len(t, panel.Spec.Data.Spec.Queries, 1)
|
||||
query := panel.Spec.Data.Spec.Queries[0]
|
||||
require.NotNil(t, query.Spec.Datasource, "Query should have datasource")
|
||||
|
||||
// Verify datasource type is "datasource"
|
||||
assert.NotNil(t, query.Spec.Datasource.Type)
|
||||
assert.Equal(t, "datasource", *query.Spec.Datasource.Type)
|
||||
|
||||
// Verify datasource UID is resolved to "grafana"
|
||||
assert.NotNil(t, query.Spec.Datasource.Uid)
|
||||
assert.Equal(t, grafanads.DatasourceUID, *query.Spec.Datasource.Uid, "type: 'datasource' with no UID should resolve to uid: 'grafana'")
|
||||
|
||||
// Verify query kind matches datasource type
|
||||
assert.Equal(t, "datasource", query.Spec.Query.Kind)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty target datasource objects inherit from panel datasource",
|
||||
createV1beta1: func() *dashv1.Dashboard {
|
||||
return &dashv1.Dashboard{
|
||||
Spec: dashv1.DashboardSpec{
|
||||
Object: map[string]interface{}{
|
||||
"title": "Test Dashboard",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 1,
|
||||
"type": "bargauge",
|
||||
// Panel datasource is set
|
||||
"datasource": map[string]interface{}{
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus-uid",
|
||||
},
|
||||
"targets": []interface{}{
|
||||
map[string]interface{}{
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk",
|
||||
// Target datasource is empty object {} - should inherit from panel
|
||||
"datasource": map[string]interface{}{},
|
||||
},
|
||||
map[string]interface{}{
|
||||
"refId": "B",
|
||||
"scenarioId": "random_walk",
|
||||
"datasource": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validateV2alpha1: func(t *testing.T, v2alpha1 *dashv2alpha1.Dashboard) {
|
||||
require.NotNil(t, v2alpha1.Spec.Elements["panel-1"])
|
||||
panel := v2alpha1.Spec.Elements["panel-1"].PanelKind
|
||||
require.NotNil(t, panel)
|
||||
|
||||
// Verify queries inherit panel datasource
|
||||
require.Len(t, panel.Spec.Data.Spec.Queries, 2)
|
||||
for _, query := range panel.Spec.Data.Spec.Queries {
|
||||
require.NotNil(t, query.Spec.Datasource, "Query should inherit datasource from panel when target datasource is empty")
|
||||
assert.Equal(t, "prometheus", *query.Spec.Datasource.Type)
|
||||
assert.Equal(t, "prometheus-uid", *query.Spec.Datasource.Uid)
|
||||
assert.Equal(t, "prometheus", query.Spec.Query.Kind)
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "panel datasource null without empty target datasource objects - no default set",
|
||||
createV1beta1: func() *dashv1.Dashboard {
|
||||
return &dashv1.Dashboard{
|
||||
Spec: dashv1.DashboardSpec{
|
||||
Object: map[string]interface{}{
|
||||
"title": "Test Dashboard",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 1,
|
||||
"type": "bargauge",
|
||||
// Panel datasource is null
|
||||
"datasource": nil,
|
||||
"targets": []interface{}{
|
||||
map[string]interface{}{
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk",
|
||||
// Target has no datasource field at all (not even empty object)
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validateV2alpha1: func(t *testing.T, v2alpha1 *dashv2alpha1.Dashboard) {
|
||||
require.NotNil(t, v2alpha1.Spec.Elements["panel-1"])
|
||||
panel := v2alpha1.Spec.Elements["panel-1"].PanelKind
|
||||
require.NotNil(t, panel)
|
||||
|
||||
// Verify queries don't have datasource when panel is null and targets don't have empty datasource objects
|
||||
require.Len(t, panel.Spec.Data.Spec.Queries, 1)
|
||||
query := panel.Spec.Data.Spec.Queries[0]
|
||||
// Query should not have datasource when panel datasource is null and target doesn't have empty datasource object
|
||||
assert.Nil(t, query.Spec.Datasource, "Query should not have datasource when panel datasource is null and target has no empty datasource object")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty panel datasource object preserved as empty",
|
||||
createV1beta1: func() *dashv1.Dashboard {
|
||||
return &dashv1.Dashboard{
|
||||
Spec: dashv1.DashboardSpec{
|
||||
Object: map[string]interface{}{
|
||||
"title": "Test Dashboard",
|
||||
"panels": []interface{}{
|
||||
map[string]interface{}{
|
||||
"id": 1,
|
||||
"type": "bargauge",
|
||||
// Panel datasource is empty object {} - should be preserved as empty
|
||||
"datasource": map[string]interface{}{},
|
||||
"targets": []interface{}{
|
||||
map[string]interface{}{
|
||||
"refId": "A",
|
||||
"scenarioId": "random_walk",
|
||||
"datasource": map[string]interface{}{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
validateV2alpha1: func(t *testing.T, v2alpha1 *dashv2alpha1.Dashboard) {
|
||||
require.NotNil(t, v2alpha1.Spec.Elements["panel-1"])
|
||||
panel := v2alpha1.Spec.Elements["panel-1"].PanelKind
|
||||
require.NotNil(t, panel)
|
||||
|
||||
// Verify queries don't have datasource when panel datasource is empty object {}
|
||||
require.Len(t, panel.Spec.Data.Spec.Queries, 1)
|
||||
query := panel.Spec.Data.Spec.Queries[0]
|
||||
// Empty objects {} should be preserved as empty, not converted to defaults
|
||||
assert.Nil(t, query.Spec.Datasource, "Query should not have datasource when panel datasource is empty object {}")
|
||||
assert.Equal(t, "", query.Spec.Query.Kind, "Query kind should be empty when datasource is empty object {}")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v1beta1Dash := tt.createV1beta1()
|
||||
|
||||
// Convert to v2alpha1
|
||||
var v2alpha1Dash dashv2alpha1.Dashboard
|
||||
err := scheme.Convert(v1beta1Dash, &v2alpha1Dash, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Validate the conversion result
|
||||
tt.validateV2alpha1(t, &v2alpha1Dash)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user