# Copyright 2020 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: kafka-ch-controller
  labels:
    contrib.eventing.knative.dev/release: devel
rules:
  - apiGroups:
      - messaging.knative.dev
    resources:
      - kafkachannels
      - kafkachannels/status
    verbs:
      - get
      - list
      - watch
      - update
      - patch
  - apiGroups:
      - messaging.knative.dev
    resources:
      - kafkachannels/finalizers
    verbs:
      - update
  - apiGroups:
      - "" # Core API group.
    resources:
      - services
      - configmaps
      - secrets
    verbs:
      - get
      - list
      - watch
      - create
  - apiGroups:
      - "" # Core API group.
    resources:
      - services
    verbs: &everything
      - get
      - list
      - watch
      - create
      - patch
      - update
  - apiGroups:
      - "" # Core API Group.
    resources:
      - configmaps
    resourceNames:
      - kafka-ch-dispatcher
    verbs:
      - update
  - apiGroups:
      - "" # Core API Group.
    resources:
      - events
    verbs:
      - create
      - patch
      - update
  - apiGroups:
      - ""
    resources:
      - configmaps
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - "" # Core API group.
    resources:
      - endpoints
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - apps
    resources:
      - deployments
      - deployments/status
    verbs: *everything
  - apiGroups:
      - "" # Core API group.
    resources:
      - serviceaccounts
    verbs: *everything
  - apiGroups:
      - rbac.authorization.k8s.io
    resources:
      - rolebindings
    verbs: *everything
  - apiGroups:
      - "coordination.k8s.io"
    resources:
      - leases
    verbs: *everything
