{{ if .Values.rbacObjects.create }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ .Values.rbacObjects.roleName }}
  {{- if .Values.namespace }}
  namespace: {{ toYaml .Values.namespace }}
  {{- end }}
  annotations:
  {{- include "custom.annotations" $ | indent 4 }}
  labels:
  {{- include "configseeder.labels" $ | indent 4 }}
  {{- include "custom.labels" $ | indent 4 }}
rules:
  - apiGroups: [""]
    resources: ["configmaps", "secrets"]
    verbs: ["create", "get", "update", "delete"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ .Values.rbacObjects.roleBindingName }}
  {{- if .Values.namespace }}
  namespace: {{ toYaml .Values.namespace }}
  {{- end }}
  annotations:
  {{- include "custom.annotations" $ | indent 4 }}
  labels:
  {{- include "configseeder.labels" $ | indent 4 }}
  {{- include "custom.labels" $ | indent 4 }}
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccount.name }}
roleRef:
  kind: Role
  name: {{ .Values.rbacObjects.roleName }}
  apiGroup: rbac.authorization.k8s.io
{{ end }}