{{- if ne .Values.schedule "now" -}}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: {{ template "mysqldump.fullname" . }}
  labels:
    app: {{ template "mysqldump.name" . }}
    chart: {{ template "mysqldump.chart" . }}
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  schedule: "{{ .Values.schedule }}"
  successfulJobsHistoryLimit: {{ .Values.successfulJobsHistoryLimit }}
  failedJobsHistoryLimit: {{ .Values.failedJobsHistoryLimit }}
  concurrencyPolicy: Forbid
  jobTemplate:
    metadata:
      labels:
        app: {{ template "mysqldump.name" . }}
        chart: {{ template "mysqldump.chart" . }}
        cronjob-name: {{ template "mysqldump.fullname" . }}
        release: "{{ .Release.Name }}"
        heritage: "{{ .Release.Service }}"
    spec:
      backoffLimit: 1
      template:
{{- $file := .Files.Get "files/job.tpl" }}
{{ tpl $file . | indent 8 }}
{{- end -}}