apiVersion: v1
kind: Secret
metadata:
  name: {{ template "metricbeat.fullname" . }}-daemonset-config
  labels:
    app: {{ template "metricbeat.name" . }}
    chart: {{ template "metricbeat.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque
data:
  metricbeat.yml: {{ toYaml .Values.daemonset.config | indent 4 | b64enc }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "metricbeat.fullname" . }}-deployment-config
  labels:
    app: {{ template "metricbeat.name" . }}
    chart: {{ template "metricbeat.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque
data:
  metricbeat.yml: {{ toYaml .Values.deployment.config | indent 4 | b64enc }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "metricbeat.fullname" . }}-daemonset-modules
  labels:
    app: {{ template "metricbeat.name" . }}
    chart: {{ template "metricbeat.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque
data:
  {{- range $key, $value := .Values.daemonset.modules }}
    {{- if eq $value.enabled true }}
      {{ $key }}.yml: {{ toYaml $value.config | indent 4 | b64enc }}
    {{- end }}
  {{- end }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "metricbeat.fullname" . }}-deployment-modules
  labels:
    app: {{ template "metricbeat.name" . }}
    chart: {{ template "metricbeat.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
type: Opaque
data:
  {{- range $key, $value := .Values.deployment.modules }}
    {{- if eq $value.enabled true }}
      {{ $key }}.yml: {{ toYaml $value.config | indent 4 | b64enc }}
    {{- end }}
  {{- end }}
