{{ if and .Values.enterprise.tokengen.enabled .Values.enterprise.enabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}RoleBinding
metadata:
  name: {{ template "enterprise-logs.tokengenFullname" . }}
  labels:
    {{- include "enterprise-logs.tokengenLabels" . | nindent 4 }}
    {{- with .Values.enterprise.tokengen.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  annotations:
    {{- with .Values.enterprise.tokengen.annotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
    "helm.sh/hook": post-install
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: {{ if not .Values.rbac.namespaced }}Cluster{{ end }}Role
  name: {{ template "enterprise-logs.tokengenFullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "enterprise-logs.tokengenFullname" . }}
    namespace: {{ $.Release.Namespace }}
{{- end }}