{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ include "trivy.fullname" . }}
  labels:
{{ include "trivy.labels" . | indent 4 }}
  namespace: {{ .Release.Namespace }}
{{- if .Values.rbac.pspEnabled }}
  {{- if .Capabilities.APIVersions.Has "policy/v1beta1/PodSecurityPolicy" }}
rules:
- apiGroups:      ['policy']
  resources:      ['podsecuritypolicies']
  verbs:          ['use']
  resourceNames:  [{{ include "trivy.fullname" . }}]
  {{- end }}
{{- end }}
{{- end }}
