{{- if .Values.e2eProber.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
  name: {{ include "probers.fullname" . }}-e2e
  labels:
    {{- include "probers.labels" . | nindent 4 }}
spec:
  schedule: "{{ .Values.e2eProber.schedule }}"
  concurrencyPolicy: Forbid
  successfulJobsHistoryLimit: 1
  failedJobsHistoryLimit: 3
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: OnFailure
          containers:
          - name: e2e-tester
            image: "{{ .Values.e2eProber.image.repository }}:{{ .Values.e2eProber.image.tag }}"
            imagePullPolicy: {{ .Values.e2eProber.image.pullPolicy }}
            # Assuming the image's entrypoint executes the test suite (e.g., `npm test` or `pytest`)
            env:
              - name: BACKEND_URL
                value: {{ .Values.e2eProber.backendUrl | quote }}
            resources:
              {{- toYaml .Values.e2eProber.resources | nindent 14 }}
{{- end }}