{{- if (and .Values.alertmanager.enabled (not .Values.alertmanager.externalConfig) ) }}
apiVersion: v1
kind: Secret
metadata:
  name: alertmanager-{{ template "kube-prometheus.alertmanager.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "kube-prometheus.alertmanager.labels" . | 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:
  alertmanager.yaml: {{ toYaml .Values.alertmanager.config | b64enc | quote }}
  {{- range $key, $val := .Values.alertmanager.templateFiles }}
  {{ $key }}: {{ $val | b64enc | quote }}
  {{- end }}
{{- end }}
