{{- if .Values.serviceAccount.create -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ include "openfga.fullname" . }}-job-status-reader
  labels:
    {{- include "openfga.labels" . | nindent 4 }}
rules:
- apiGroups:
  - batch
  resources:
  - jobs
  verbs:
  - get
  - list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ include "openfga.fullname" . }}-job-status-reader
  labels:
    {{- include "openfga.labels" . | nindent 4 }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: {{ include "openfga.fullname" . }}-job-status-reader
subjects:
- kind: ServiceAccount
  name: {{ include "openfga.serviceAccountName" . }}
{{- end }}
