{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- 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.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 }}
