# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Authors.

{{- if .Values.images.jobs.mongodbMigration }}
apiVersion: batch/v1
kind: Job
metadata:
  labels: {{ include "labels.mongodbMigration" . | nindent 4 }}
  name: "{{ include "name" . }}-job-mongodb-migration"
  namespace: {{ .Release.Namespace }}
  annotations:
    "helm.sh/hook": pre-upgrade
    "helm.sh/hook-weight": "-1"
    "helm.sh/hook-delete-policy": before-hook-creation
spec:
  ttlSecondsAfterFinished: 300
  template:
    metadata:
      labels: {{ include "labels.mongodbMigration" . | nindent 8 }}
    spec:
      restartPolicy: Never
      {{- include "image.imagePullSecrets" . | nindent 6 }}
      containers: {{ include "containerMongodbMigration" . | nindent 8 }}
      nodeSelector: {{ toYaml .Values.mongodbMigration.nodeSelector | nindent 8 }}
      tolerations: {{ toYaml .Values.mongodbMigration.tolerations | nindent 8 }}
      securityContext: {{ include "securityContext" . | nindent 8 }}
  backoffLimit: 0
{{- end}}
