Merge "[SDC] Bring back sdc onboarding volume mount permissions"
[oom.git] / kubernetes / multicloud / charts / multicloud-prometheus / charts / prometheus-grafana / templates / configmap.yaml
1 {{/*
2 # Copyright 2018 Intel Corporation, Inc
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 {{- if .Values.global.grafana.enabled -}}
18
19 apiVersion: v1
20 kind: ConfigMap
21 metadata:
22   name: {{ include "common.fullname" . }}
23   namespace: {{ include "common.namespace" . }}
24   labels:
25     app: {{ include "common.name" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ include "common.release" . }}
28     heritage: {{ .Release.Service }}
29 data:
30 {{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }}
31
32 {{- if .Values.datasources }}
33   {{- range $key, $value := .Values.datasources }}
34   {{ $key }}: |
35 {{ toYaml $value | indent 4 }}
36   {{- end -}}
37 {{- end -}}
38
39 {{- if .Values.dashboardProviders }}
40   {{- range $key, $value := .Values.dashboardProviders }}
41   {{ $key }}: |
42 {{ toYaml $value | indent 4 }}
43   {{- end -}}
44 {{- end -}}
45
46 {{- if .Values.dashboards  }}
47   download_dashboards.sh: |
48     #!/usr/bin/env sh
49     set -euf
50     {{- if .Values.dashboardProviders }}
51       {{- range $key, $value := .Values.dashboardProviders }}
52         {{- range $value.providers }}
53     mkdir -p {{ .options.path }}
54         {{- end }}
55       {{- end }}
56     {{- end }}
57   {{- range $provider, $dashboards := .Values.dashboards }}
58     {{- range $key, $value := $dashboards }}
59       {{- if (or (hasKey $value "gnetId") (hasKey $value "url")) }}
60     curl -sk \
61     --connect-timeout 60 \
62     --max-time 60 \
63     -H "Accept: application/json" \
64     -H "Content-Type: application/json;charset=UTF-8" \
65     {{- 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 }} \
66     > /var/lib/grafana/dashboards/{{ $provider }}/{{ $key }}.json
67       {{- end }}
68     {{- end }}
69   {{- end }}
70 {{- end }}
71
72 {{- if .Values.dashboards }}
73   {{- range $provider, $dashboards := .Values.dashboards }}
74 ---
75 apiVersion: v1
76 kind: ConfigMap
77 metadata:
78   name: {{ include "common.fullname" $ }}-dashboards-{{ $provider }}
79   namespace: {{ include "common.namespace" $ }}
80   labels:
81     app: {{ include "common.name" $ }}
82     chart: {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
83     release: {{ include "common.release" $ }}
84     heritage: {{ $.Release.Service }}
85     dashboard-provider: {{ $provider }}
86 data:
87   {{- range $key, $value := $dashboards }}
88     {{- if hasKey $value "json" }}
89   {{ $key }}.json: |
90 {{ $value.json | indent 4 }}
91     {{- end }}
92   {{- end }}
93   {{- end }}
94
95 {{- end }}
96 {{- end -}}