{{- if .Values.metrics.dashboards.create }}
{{- $namespace := .Values.metrics.dashboards.namespace | default $.Release.Namespace }}
{{- range $path, $_ :=  .Files.Glob  "dashboards/*.json" }}
{{- $filename := trimSuffix (ext $path) (base $path) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-%s" (include "sealed-secrets.fullname" $) $filename }}
  namespace: {{ $namespace }}
  labels: {{- include "sealed-secrets.labels" $ | nindent 4 }}
    {{- if $.Values.metrics.dashboards.labels }}
    {{- include "sealed-secrets.render" ( dict "value" $.Values.metrics.dashboards.labels "context" $) | nindent 4 }}
    {{- end }}
    {{- if $.Values.commonLabels }}
    {{- include "sealed-secrets.render" (dict "value" $.Values.commonLabels "context" $) | nindent 4 }}
    {{- end }}
  annotations:
    {{- if $.Values.metrics.dashboards.annotations }}
    {{- include "sealed-secrets.render" ( dict "value" $.Values.metrics.dashboards.annotations "context" $) | nindent 4 }}
    {{- end }}
    {{- if $.Values.commonAnnotations }}
    {{- include "sealed-secrets.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
    {{- end }}
data:
  {{ base $path }}: |-
{{ $.Files.Get $path | indent 4 }}
---
{{- end }}
{{- end }}
