# helm_charts_rolebindings.yaml
{{- $values := .Values }}
{{- range .Values.roleBindings }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ .name }}
  {{- if hasKey $values "namespace" }}
  namespace: {{ $values.namespace }}
  {{- end }}
  labels:
    chart: {{ template "magic-namespace.chart" $ }}
    release: {{ $.Release.Name }}
    heritage: {{ $.Release.Service }}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: {{ .role.kind }}
  name: {{ .role.name }}
subjects:
- kind: {{ .subject.kind }}
  name: {{ .subject.name }}
{{- end }}