{{- /*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "common.names.fullname" . }}-envvars
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: grafana
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  GF_SECURITY_ADMIN_USER: {{ .Values.admin.user | quote }}
  {{- if .Values.imageRenderer.enabled }}
  GF_RENDERING_SERVER_URL: {{ .Values.imageRenderer.serverURL | quote }}
  GF_RENDERING_CALLBACK_URL: {{ .Values.imageRenderer.callbackURL | quote }}
  {{- end }}
  {{- if .Values.plugins }}
  GF_INSTALL_PLUGINS: {{ .Values.plugins | quote }}
  {{- else }}
  GF_INSTALL_PLUGINS: ""
  {{- end }}
  GF_PATHS_PLUGINS: "/opt/bitnami/grafana/data/plugins"
  GF_AUTH_LDAP_ENABLED: {{ .Values.ldap.enabled | quote }}
  GF_AUTH_LDAP_CONFIG_FILE: "/opt/bitnami/grafana/conf/ldap.toml"
  GF_AUTH_LDAP_ALLOW_SIGN_UP: {{ .Values.ldap.allowSignUp | quote }}
  GF_PATHS_PROVISIONING: "/opt/bitnami/grafana/conf/provisioning"
  GF_PATHS_CONFIG: "/opt/bitnami/grafana/conf/grafana.ini"
  GF_PATHS_DATA: "/opt/bitnami/grafana/data"
  GF_PATHS_LOGS: "/opt/bitnami/grafana/logs"
