{{- if (or (and (ne (.Values.client.enabled | toString) "-") .Values.client.enabled) (and (eq (.Values.client.enabled | toString) "-") .Values.global.enabled)) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ template "consul.fullname" . }}-client
  labels:
    app: {{ template "consul.name" . }}
    chart: {{ template "consul.chart" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
{{- if (or .Values.global.enablePodSecurityPolicies .Values.global.bootstrapACLs) }}
rules:
{{- if .Values.global.enablePodSecurityPolicies }}
  - apiGroups: ["policy"]
    resources: ["podsecuritypolicies"]
    resourceNames:
    - {{ template "consul.fullname" . }}-client
    verbs:
    - use
{{- end }}
{{- if .Values.global.bootstrapACLs }}
  - apiGroups: [""]
    resources:
      - secrets
    resourceNames:
      - {{ template "consul.fullname" . }}-client-acl-token
    verbs:
      - get
{{- end }}
{{- else}}
rules: []
{{- end }}
{{- end }}
