{{- if .Values.upgradeCRDs }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: {{ include "velero.fullname" . }}-upgrade-crds
  annotations:
    "helm.sh/hook": pre-install,pre-upgrade,pre-rollback
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  labels:
    app.kubernetes.io/component: upgrade-crds
    app.kubernetes.io/name: {{ include "velero.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "velero.chart" . }}
rules:
- apiGroups: 
    - "apiextensions.k8s.io"
  resources: 
    - "customresourcedefinitions"
  verbs: 
    - create
    - patch
    - update
    - get
    - list
{{- end }}
