apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: amqp-webhook
  labels:
    amqp.eventing.knative.dev/release: devel
rules:
  # For watching logging configuration and getting certs.
  - apiGroups:
      - ""
    resources:
      - "configmaps"
    verbs:
      - "get"
      - "list"
      - "watch"

  # For manipulating certs into secrets.
  - apiGroups:
      - ""
    resources:
      - "secrets"
      - "namespaces"
    verbs:
      - "get"
      - "create"
      - "update"
      - "list"
      - "watch"
      - "patch"

  # For getting our Deployment so we can decorate with ownerref.
  - apiGroups:
      - "apps"
    resources:
      - "deployments"
    verbs:
      - "get"

  - apiGroups:
      - "apps"
    resources:
      - "deployments/finalizers"
    verbs:
      - update

  # For actually registering our webhook.
  - apiGroups:
      - "admissionregistration.k8s.io"
    resources:
      - "mutatingwebhookconfigurations"
      - "validatingwebhookconfigurations"
    verbs: &everything
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "patch"
      - "watch"

  # For leader election
  - apiGroups:
      - "coordination.k8s.io"
    resources:
      - "leases"
    verbs: *everything