# ClusterRoleBinding for Tekton Triggers
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tekton-triggers-binding
  labels:
    app.kubernetes.io/name: {{ .Values.labels.app.name }}
    app.kubernetes.io/component: triggers
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccounts.triggers.name }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: ClusterRole
  name: tekton-triggers-role
  apiGroup: rbac.authorization.k8s.io
---
# ClusterRoleBinding for Pipeline execution
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tekton-pipeline-binding
  labels:
    app.kubernetes.io/name: {{ .Values.labels.app.name }}
    app.kubernetes.io/component: pipeline
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccounts.pipeline.name }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: ClusterRole
  name: tekton-pipeline-role
  apiGroup: rbac.authorization.k8s.io
---
# RoleBinding for EventListener
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: tekton-triggers-eventlistener-binding
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: {{ .Values.labels.app.name }}
    app.kubernetes.io/component: triggers
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccounts.triggers.name }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: tekton-triggers-eventlistener-role
  apiGroup: rbac.authorization.k8s.io