Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grafana] Improve dashboards download script #3350

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/grafana/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: grafana
version: 8.5.2
version: 8.5.3
appVersion: 11.2.1
kubeVersion: "^1.8.0-0"
description: The leading tool for querying and visualizing time series and metrics.
Expand Down
9 changes: 8 additions & 1 deletion charts/grafana/templates/_config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ download_dashboards.sh: |
{{- range $provider, $dashboards := .Values.dashboards }}
{{- range $key, $value := $dashboards }}
{{- if (or (hasKey $value "gnetId") (hasKey $value "url")) }}
curl -skf \
{{- if $value.url }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, if someone changes the URL logic below, this may get forgotten. Not sure, if it make sense to move the Source URL logic to a dedicated template helper.

WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkroepke i assume that if the logic is changed then lines 120 and below will also be changed right ? :

not sure for now it worth it to move it into a helper template even though it would better in the future :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @zanhsieh has an opinion here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xinity @jkroepke
I would prefer

  1. Move source url to the _helper.tpl
  2. Set default revision as 1 as well set default source url.
  3. Move echo "downloading: {{ $key }} dashboard" out of if since both conditions output that string.

echo "downloading: {{ $key }} dashboard"
echo "Source Url: {{ $value.url }}"
{{- else }}
echo "downloading {{ $key }} dashboard"
echo "Source Url: https://grafana.com/api/dashboards/{{ $value.gnetId }}/revisions/{{- if $value.revision -}}{{ $value.revision }}{{- else -}}1{{- end -}}/download"
{{- end }}
curl -skf --show-error \
--connect-timeout 60 \
--max-time 60 \
{{- if not $value.b64content }}
Expand Down
2 changes: 1 addition & 1 deletion charts/grafana/templates/_pod.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ initContainers:
{{- end }}
imagePullPolicy: {{ .Values.downloadDashboardsImage.pullPolicy }}
command: ["/bin/sh"]
args: [ "-c", "mkdir -p /var/lib/grafana/dashboards/default && /bin/sh -x /etc/grafana/download_dashboards.sh" ]
args: [ "-c", "mkdir -p /var/lib/grafana/dashboards/default && /bin/sh /etc/grafana/download_dashboards.sh" ]
{{- with .Values.downloadDashboards.resources }}
resources:
{{- toYaml . | nindent 6 }}
Expand Down
Loading