# API Key
{{- if not .Values.datadog.apiKeyExistingSecret }}

apiVersion: v1
kind: Secret
metadata:
  name: {{ template "datadog.fullname" . }}
  labels:
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/name: "{{ template "datadog.fullname" . }}"
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
type: Opaque
data:
  api-key: {{ default "MISSING" .Values.datadog.apiKey | b64enc | quote }}

{{- end }}

# APP Key
{{- if not .Values.datadog.appKeyExistingSecret }}
{{- if and .Values.clusterAgent.enabled .Values.clusterAgent.metricsProvider.enabled }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "datadog.appKeySecretName" . }}
  labels:
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/name: "{{ template "datadog.fullname" . }}"
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
type: Opaque
data:
  app-key: {{ default "MISSING" .Values.datadog.appKey | b64enc | quote }}
{{- end }}
{{- end }}
