{{ if and (and .Values.enterprise.provisioner.enabled .Values.enterprise.enabled) (not .Values.rbac.namespaced)}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: {{ template "enterprise-logs.provisionerFullname" . }}
  namespace: {{ $.Release.Namespace }}
  labels:
    {{- include "enterprise-logs.provisionerLabels" . | nindent 4 }}
    {{- with .Values.enterprise.provisioner.labels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  annotations:
    {{- with .Values.enterprise.provisioner.annotations }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
    "helm.sh/hook": post-install
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template "enterprise-logs.provisionerFullname" . }}
subjects:
  - kind: ServiceAccount
    name: {{ template "enterprise-logs.provisionerFullname" . }}
    namespace: {{ $.Release.Namespace }}
{{- end }}