{{- if not .Values.datadog.appKeyExistingSecret }}
{{- if and .Values.clusterAgent.enabled .Values.clusterAgent.metricsProvider.enabled }}

apiVersion: v1
kind: Secret
metadata:
  name: {{ template "datadog.appKeySecretName" . }}
  labels:
    app: "{{ template "datadog.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
type: Opaque
data:
  app-key: {{ default "MISSING" .Values.datadog.appKey | b64enc | quote }}
{{- end }}
{{- end }}
