# helm_charts_agent-secret.yaml
{{- if not .Values.clusterAgent.tokenExistingSecret }}
{{- if .Values.clusterAgent.enabled -}}

apiVersion: v1
kind: Secret
metadata:
  name: {{ template "datadog.fullname" . }}-cluster-agent
  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:
  {{ if .Values.clusterAgent.token -}}
  token: {{ .Values.clusterAgent.token | b64enc | quote }}
  {{ else -}}
  token: {{ randAlphaNum 32 | b64enc | quote }}
  {{ end }}
{{- end }}

{{ end }}