
{{- if $.Values.cronJobs.e2e.enabled }}

apiVersion: batch/v1
kind: CronJob
metadata:
  name: e2e-cron
  namespace: {{ $.Release.Namespace }}
  labels: 
    appname: oneuptime
    app.kubernetes.io/part-of: oneuptime
    app.kubernetes.io/managed-by: Helm
    date: "{{ now | unixEpoch }}"
spec:
  schedule: "*/30 * * * *" # At every 30 minute.
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: e2e-cron
            image: {{ printf "%s/%s/%s:%s" $.Values.image.registry $.Values.image.repository "e2e" $.Values.image.tag }}
            imagePullPolicy: {{ $.Values.image.pullPolicy }}
            env:
              {{- include "oneuptime.env.common" . | nindent 14 }}
              - name: E2E_TEST_IS_USER_REGISTERED
                value: {{ $.Values.cronJobs.e2e.isUserRegistered | quote }}
              - name: E2E_TEST_REGISTERED_USER_EMAIL
                value: {{ $.Values.cronJobs.e2e.registeredUserEmail | quote }}
              - name: E2E_TEST_REGISTERED_USER_PASSWORD
                value: {{ $.Values.cronJobs.e2e.registeredUserPassword | quote }}
              - name: E2E_TEST_STATUS_PAGE_URL
                value: {{ $.Values.cronJobs.e2e.statusPageUrl | quote }}
              - name: E2E_TESTS_FAILED_WEBHOOK_URL
                value: {{ $.Values.cronJobs.e2e.failedWebhookUrl | quote }}
          restartPolicy: Never

{{- end }}