{{- if (.Values.config) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "common.names.fullname" . }}-config
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  ephemerup.hcl: |-
    listen = {{ .Values.config.listen | quote }}
    bodylimit = {{ .Values.config.bodylimit | quote }}
    {{- if .Values.config.url }}
    url = {{ .Values.config.url | quote }}
    {{- end }}
    super = {{ .Values.config.super | quote }}
    mail = {
      server = {{ .Values.config.mail.server | quote }}
      port = {{ .Values.config.mail.port | quote }}
      from = {{ .Values.config.mail.from | quote }}
      {{- if .Values.config.password }}
      password = {{ .Values.config.password | quote }}
      {{- end }}
    }
    apicontexts = [
    {{- range $context := .Values.config.apicontexts }}
      {
        context = {{ $context.context | quote }}
        key = {{ $context.key | quote }}
      }
    {{- end }}
    ]
    storagedir = "/data"
{{- end }}
