From 60b2dbc1c65e783245ec8134ecb7b6ff0619a4b7 Mon Sep 17 00:00:00 2001 From: Johannes Wienke Date: Sat, 11 Apr 2020 17:31:47 +0200 Subject: [PATCH] Only replace variable datasources in shared dashboards (#21710) Avoid replacing hard-coded datasource entries in shared dashboards on downloading them. This is the root causes for #21541, where the following data source is also replace: ```json "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, ``` To avoid this situation, this commit adds the requirement that the datasource entry to replace starts with a dollar sign as the first character in the quoted string region. This was the case for all dashboards that I have checked. fixes #21541 Signed-off-by: Johannes Wienke --- stable/grafana/Chart.yaml | 2 +- stable/grafana/templates/configmap.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stable/grafana/Chart.yaml b/stable/grafana/Chart.yaml index cb5d9d00b6..1e22e8ba19 100644 --- a/stable/grafana/Chart.yaml +++ b/stable/grafana/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: grafana -version: 5.0.11 +version: 5.0.12 appVersion: 6.7.1 kubeVersion: "^1.8.0-0" description: The leading tool for querying and visualizing time series and metrics. diff --git a/stable/grafana/templates/configmap.yaml b/stable/grafana/templates/configmap.yaml index 00c6957274..a86638b8fa 100644 --- a/stable/grafana/templates/configmap.yaml +++ b/stable/grafana/templates/configmap.yaml @@ -61,7 +61,7 @@ data: -H "Accept: application/json" \ -H "Content-Type: application/json;charset=UTF-8" \ {{ end }} - {{- if $value.url -}}{{ $value.url }}{{- else -}} https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download{{- end -}}{{ if $value.datasource }}| sed 's|\"datasource\":[^,]*|\"datasource\": \"{{ $value.datasource }}\"|g'{{ end }}{{- if $value.b64content -}} | base64 -d {{- end -}} \ + {{- if $value.url -}}{{ $value.url }}{{- else -}} https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download{{- end -}}{{ if $value.datasource }}| sed 's|\"datasource\": *\"\$[^,]*|\"datasource\": \"{{ $value.datasource }}\"|g'{{ end }}{{- if $value.b64content -}} | base64 -d {{- end -}} \ > /var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json {{- end -}} {{- end }}