{{- if .Values.minio.rootUser.serviceAccounts }}
apiVersion: v1
kind: Secret
metadata:
  name: deploykf-minio-root-user-service-accounts
  labels:
    helm.sh/chart: {{ include "deploykf-minio.labels.chart" . }}
    app.kubernetes.io/name: {{ include "deploykf-minio.labels.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: minio
data:
  {{- range $index, $sa := .Values.minio.rootUser.serviceAccounts }}
  {{ printf "%d_policy_json" $index | quote }}: {{ if $sa.policy }}{{ $sa.policy | toJson | b64enc | quote }}{{ else }}""{{ end }}
  {{- if not $sa.existingSecret }}
  {{ printf "%d_access_key" $index | quote }}: {{ $sa.accessKey | b64enc | quote }}
  {{ printf "%d_secret_key" $index | quote }}: {{ $sa.secretKey | b64enc | quote }}
  {{- end }}
  {{- end }}
{{- end }}