{{- if (or (.Values.datadog.confd) (.Values.datadog.autoconf)) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "datadog.confd.fullname" . }}
  labels:
    app: "{{ template "datadog.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
  annotations:
    checksum/confd-config: {{ toYaml .Values.datadog.confd | sha256sum }}
    checksum/autoconf-config: {{ toYaml .Values.datadog.autoconf | sha256sum }}
data:
{{/*
Merge the legacy autoconf dict before so confd static configurations
override duplicates
*/}}
{{- if .Values.datadog.autoconf }}
{{ toYaml .Values.datadog.autoconf | indent 2 }}
{{- end -}}
{{- if .Values.datadog.confd }}
{{ toYaml .Values.datadog.confd | indent 2 }}
{{- end -}}
{{- end -}}
