{{ if .Values.hub.rbac.create }}
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: {{ printf "%s-hub" (include "common.names.fullname" .) }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: hub
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
rules:
  - apiGroups: [""]
    resources: ["pods", "persistentvolumeclaims"]
    verbs: ["get", "watch", "list", "create", "delete"]
  - apiGroups: [""]       # "" indicates the core API group
    resources: ["events"]
    verbs: ["get", "watch", "list"]
  {{- if .Values.hub.rbac.rules }}
  {{- include "common.tplvalues.render" ( dict "value" .Values.hub.rbac.rules "context" $ ) | nindent 2 }}
  {{- end }}
{{- end }}
