{{- if or .Values.mysql.rootUser.generateSecret .Values.mysql.kubeflowUser.generateSecret }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: deploykf-mysql-generate-jobs
  labels:
    helm.sh/chart: {{ include "deploykf-mysql.labels.chart" . }}
    app.kubernetes.io/name: {{ include "deploykf-mysql.labels.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: generate
  annotations:
    helm.sh/hook: pre-install,pre-upgrade
    helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
rules:
  ## needed by the "generate-secrets" job for storing/retrieving generated secrets
  - apiGroups:
      - ""
    resources:
      - secrets
    verbs:
      - get
      - list
      - watch
      - create
      - update
      - patch
      - delete
{{- end }}