apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: metering-admins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: metering-admin
subjects:
{{- range .Values.permissions.meteringAdmins }}
- kind: "{{ .kind }}"
  name: "{{ .name }}"
{{- if .namespace }}
  namespace: "{{ .namespace }}"
{{- end }}
{{- if .apiGroup }}
  apiGroup: "{{ .apiGroup }}"
{{- end }}
{{- end }}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: metering-viewers
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: metering-viewer
subjects:
{{- range .Values.permissions.meteringViewers }}
- kind: "{{ .kind }}"
  name: "{{ .name }}"
{{- if .namespace }}
  namespace: "{{ .namespace }}"
{{- end }}
{{- if .apiGroup }}
  apiGroup: "{{ .apiGroup }}"
{{- end }}
{{- end }}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: reporting-admins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: reporting-admin
subjects:
{{- range .Values.permissions.reportingAdmins }}
- kind: "{{ .kind }}"
  name: "{{ .name }}"
{{- if .namespace }}
  namespace: "{{ .namespace }}"
{{- end }}
{{- if .apiGroup }}
  apiGroup: "{{ .apiGroup }}"
{{- end }}
{{- end }}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: reporting-viewers
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: reporting-viewer
subjects:
{{- range .Values.permissions.reportingViewers }}
- kind: "{{ .kind }}"
  name: "{{ .name }}"
{{- if .namespace }}
  namespace: "{{ .namespace }}"
{{- end }}
{{- if .apiGroup }}
  apiGroup: "{{ .apiGroup }}"
{{- end }}
{{- end }}

---

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: report-exporters
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: report-exporter
subjects:
{{- range .Values.permissions.reportExporters }}
- kind: "{{ .kind }}"
  name: "{{ .name }}"
{{- if .namespace }}
  namespace: "{{ .namespace }}"
{{- end }}
{{- if .apiGroup }}
  apiGroup: "{{ .apiGroup }}"
{{- end }}
{{- end }}
