{{- if .Values.clusterAgent.enabled -}}

apiVersion: v1
kind: Secret
metadata:
  name: {{ template "datadog.clusterAgent.fullname" . }}
  labels:
    app: "{{ template "datadog.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
type: Opaque
data:
  {{ if .Values.clusterAgent.token -}}
  token: {{ .Values.clusterAgent.token | b64enc | quote }}
  {{ else -}}
  token: {{ randAlphaNum 32 | b64enc | quote }}
  {{ end }}
{{- end }}
