{{- if (and .Values.alertmanager.enabled (not .Values.alertmanager.externalConfig) ) }}
apiVersion: v1
kind: Secret
metadata:
  name: alertmanager-{{ template "kube-prometheus.alertmanager.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels: {{- include "kube-prometheus.alertmanager.labels" . | nindent 4 }}
data:
  alertmanager.yaml: {{ toYaml .Values.alertmanager.config | b64enc | quote }}
{{- range $key, $val := .Values.alertmanager.templateFiles }}
  {{ $key }}: {{ $val | b64enc | quote }}
{{- end }}
{{- end }}
