{{ if eq $.Values.app.envs.QUARKUS_OPERATOR_SDK_CONTROLLERS_WANAKU_CAPABILITY_NAMESPACES "JOSDK_WATCH_CURRENT" }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: wanaku-capability-role-binding
  namespace: {{ $.Release.Namespace }}
  labels:
    app.kubernetes.io/name: {{ .Chart.Name }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    app.kubernetes.io/managed-by: quarkus
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: {{ $.Release.Namespace }}-wanaku-capability-cluster-role
subjects:
  - kind: ServiceAccount
    name: {{ $.Chart.Name }}
    namespace: {{ $.Release.Namespace }}
{{ else if eq $.Values.app.envs.QUARKUS_OPERATOR_SDK_CONTROLLERS_WANAKU_CAPABILITY_NAMESPACES "JOSDK_ALL_NAMESPACES" }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: wanaku-capability-role-binding
  labels:
    app.kubernetes.io/name: {{ .Chart.Name }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    app.kubernetes.io/managed-by: quarkus
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: {{ $.Release.Namespace }}-wanaku-capability-cluster-role
subjects:
  - kind: ServiceAccount
    name: {{ $.Chart.Name }}
    namespace: {{ $.Release.Namespace }}
{{ else }}
{{ range $anamespace := ( split "," $.Values.app.envs.QUARKUS_OPERATOR_SDK_CONTROLLERS_WANAKU_CAPABILITY_NAMESPACES ) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: wanaku-capability-role-binding
  namespace: {{ $anamespace }}
  labels:
    app.kubernetes.io/name: {{ $.Chart.Name }}
    app.kubernetes.io/version: {{ $.Chart.AppVersion }}
    app.kubernetes.io/managed-by: quarkus
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: {{ $.Release.Namespace }}-wanaku-capability-cluster-role
subjects:
  - kind: ServiceAccount
    name: {{ $.Chart.Name }}
    namespace: {{ $.Release.Namespace }}
---
{{- end }}
{{- end }}
