{{- if and .Values.dashboard.rbac.create .Values.dashboard.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "goldilocks.fullname" . }}-dashboard
  labels:
    app.kubernetes.io/name: {{ include "goldilocks.name" . }}
    helm.sh/chart: {{ include "goldilocks.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: dashboard
rules:
  - apiGroups:
      - 'autoscaling.k8s.io'
    resources:
      - 'verticalpodautoscalers'
    verbs:
      - 'get'
      - 'list'
  - apiGroups:
      - 'apps'
    resources:
      - '*'
    verbs:
      - 'get'
      - 'list'
  - apiGroups:
      - ''
    resources:
      - 'namespaces'
      - 'pods'
    verbs:
      - 'get'
      - 'list'
  {{- if .Values.dashboard.rbac.enableArgoproj }}
  - apiGroups:
      - 'argoproj.io'
    resources:
      - rollouts
    verbs:
      - 'get'
      - 'list'
  {{- end }}
{{- end }}
