{{- if .Values.msgTopologyOperator.rbac.create }}
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
kind: ClusterRole
metadata:
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: messaging-topology-operator
    app.kubernetes.io/part-of: rabbitmq
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  name: {{ template "rmqco.msgTopologyOperator.fullname.namespace" . }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
rules:
  - apiGroups:
      - ""
    resources:
      - events
    verbs:
      - create
      - get
      - patch
  - apiGroups:
      - ""
    resources:
      - secrets
    verbs:
      - create
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - bindings
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - bindings/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - exchanges
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - exchanges/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - federations
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - federations/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - permissions
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - permissions/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - policies
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - policies/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - queues
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - queues/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - rabbitmqclusters
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - rabbitmqclusters/status
    verbs:
      - get
  - apiGroups:
      - rabbitmq.com
    resources:
      - schemareplications
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - schemareplications/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - shovels
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - shovels/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - superstreams
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - superstreams/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - users
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - users/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - vhosts
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - vhosts/status
    verbs:
      - get
      - patch
      - update
  - apiGroups:
      - rabbitmq.com
    resources:
      - topicpermissions
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
  - apiGroups:
      - rabbitmq.com
    resources:
      - topicpermissions/status
    verbs:
      - get
      - patch
      - update
{{- end }}
