kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: tekton-cloudevents-controller-cluster-access
  labels:
    app.kubernetes.io/component: tekton-cloudevents-controller
    app.kubernetes.io/instance: default
    app.kubernetes.io/part-of: tekton-cloudevents
rules:
  # Controller needs cluster access to all Run CRs.
  - apiGroups: ["tekton.dev"]
    resources: ["pipelineruns"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["tekton.dev"]
    resources: ["pipelineruns/finalizers"]
    verbs: ["get", "list", "watch"]
  - apiGroups: ["tekton.dev"]
    resources: ["pipelineruns/status"]
    verbs: ["get", "list", "watch"]

  # Controller needs permission to configure master-election.
  - apiGroups: ["coordination.k8s.io"]
    resources: ["leases"]
    verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]

  # Controller needs permission to emit events associated with Run CRs.
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["get", "list", "watch", "create", "update", "delete", "patch"]
