# 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.

# Use this aggregated ClusterRole when you need readonly access to "Addressables"
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: addressable-resolver
  labels:
    eventing.knative.dev/release: devel
aggregationRule:
  clusterRoleSelectors:
  - matchLabels:
      duck.knative.dev/addressable: "true"
rules: [] # Rules are automatically filled in by the controller manager.

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: service-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - ""
  resources:
  - services
  verbs:
  - get
  - list
  - watch

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: serving-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - serving.knative.dev
  resources:
  - routes
  - routes/status
  - services
  - services/status
  verbs:
  - get
  - list
  - watch

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: channel-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - messaging.knative.dev
  resources:
  - channels
  - channels/status
  verbs:
  - get
  - list
  - watch

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: broker-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - eventing.knative.dev
  resources:
  - brokers
  - brokers/status
  verbs:
  - get
  - list
  - watch

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: messaging-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - messaging.knative.dev
  resources:
  - sequences
  - sequences/status
  - parallels
  - parallels/status
  verbs:
  - get
  - list
  - watch

---

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: flows-addressable-resolver
  labels:
    eventing.knative.dev/release: devel
    duck.knative.dev/addressable: "true"
# Do not use this role directly. These rules will be added to the "addressable-resolver" role.
rules:
- apiGroups:
  - flows.knative.dev
  resources:
  - sequences
  - sequences/status
  - parallels
  - parallels/status
  verbs:
  - get
  - list
  - watch
