# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: knative-eventing-sources-controller
  labels:
    eventing.knative.dev/release: devel
rules:
  - apiGroups:
      - ""
    resources:
      - "secrets"
      - "configmaps"
      - "services"
    verbs: &everything
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "patch"
      - "watch"

  # Deployments admin
  - apiGroups:
      - "apps"
    resources:
      - "deployments"
    verbs: *everything

  # Source resources and statuses we care about.
  - apiGroups:
      - "sources.knative.dev"
    resources:
      - "sinkbindings"
      - "sinkbindings/status"
      - "sinkbindings/finalizers"
      - "apiserversources"
      - "apiserversources/status"
      - "apiserversources/finalizers"
      - "pingsources"
      - "pingsources/status"
      - "pingsources/finalizers"
    verbs: *everything

  # Legacy Source resources and statuses we care about.
  - apiGroups:
      - "sources.eventing.knative.dev"
    resources:
      - "cronjobsources"
      - "cronjobsources/status"
      - "cronjobsources/finalizers"
      - "containersources"
      - "containersources/status"
      - "containersources/finalizers"
      - "sinkbindings"
      - "sinkbindings/status"
      - "sinkbindings/finalizers"
      - "apiserversources"
      - "apiserversources/status"
      - "apiserversources/finalizers"
    verbs: *everything

  # Knative Services admin
  - apiGroups:
      - serving.knative.dev
    resources:
      - services
    verbs: *everything

  # EventTypes admin
  - apiGroups:
      - eventing.knative.dev
    resources:
      - eventtypes
    verbs: *everything

  # Events admin
  - apiGroups:
      - ""
    resources:
      - events
    verbs: *everything

  # Authorization checker
  - apiGroups:
      - authorization.k8s.io
    resources:
      - subjectaccessreviews
    verbs:
      - create
