{{- if not .Values.clusterAgent.tokenExistingSecret }}
{{- if eq (include "should-deploy-cluster-agent" .) "true" -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "clusterAgent.tokenSecretName" . }}
  namespace: {{ .Release.Namespace }}
  labels:
{{ include "datadog.labels" . | indent 4 }}
type: Opaque
data:
  {{ if .Values.clusterAgent.token -}}
  token: {{ .Values.clusterAgent.token | b64enc | quote }}
  {{ else -}}
  token: {{ randAlphaNum 32 | b64enc | quote }}
  {{ end }}
{{- end }}
{{ end }}
