{{ if .Values.orborus.rbac.create }}
kind: Role
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
  name: {{ include "shuffle.orborus.name" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "shuffle.orborus.labels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
rules:
  {{- if .Values.orborus.manageWorkerDeployments }}
  - verbs:
      - list
      - create
      - delete
    apiGroups:
      - ''
    resources:
      - pods
      - services
  - verbs:
      - list
      - create
      - delete
    apiGroups:
      - apps
    resources:
      - deployments
  {{- else }}
  - verbs:
      - list
    apiGroups:
      - ''
    resources:
      - pods
      - services
  - verbs:
      - list
    apiGroups:
      - apps
    resources:
      - deployments
  {{- end }}
{{- end }}
