{{- if .Values.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "metricbeat.fullname" . }}-config
  labels:
    app: "{{ template "metricbeat.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.metricbeatConfig }}
  {{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if and .Values.daemonset.enabled .Values.daemonset.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "metricbeat.fullname" . }}-daemonset-config
  labels:
    app: "{{ template "metricbeat.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.daemonset.metricbeatConfig }}
  {{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}

{{- if and .Values.deployment.enabled .Values.deployment.metricbeatConfig }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "metricbeat.fullname" . }}-deployment-config
  labels:
    app: "{{ template "metricbeat.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.deployment.metricbeatConfig }}
  {{ $path }}: |
{{ $config | indent 4 -}}
{{- end -}}
{{- end -}}
