---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ include "susecve.fullname" . }}-predeploy-job
  {{- with .Values.job.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
  template:
    spec:
    {{- if .Values.imagePullSecrets }}
      imagePullSecrets:
      - name: {{ .Values.imagePullSecrets }}
    {{- end }}
      securityContext:
        runAsUser: {{ .Values.securityContextPull.runAsUser }}
        runAsGroup: {{ .Values.securityContextPull.runAsGroup }}
        fsGroup: {{ .Values.securityContextPull.fsGroup }}
      containers:
      - image: "{{ .Values.image_pull.repository }}:{{ .Values.image_pull.tag }}"
        imagePullPolicy: {{ .Values.image_pull.imagePullPolicy }}
        name: {{ .Chart.Name }}
        {{- with .Values.environment_pull }}
        env:
{{ toYaml . | indent 10 }}
        {{- end }}
        command: ["/bin/sh"]
        args:
          - -c
          - ls -ahl /opt && su wwwrun -m -c /opt/check-repo.sh
        {{- with .Values.resources_pull }}
        resources:
{{ toYaml . | indent 10 }}
        {{- end }}
        volumeMounts:
          - mountPath: {{ .Values.mountPath_pull }}
            name: susecve-data
      volumes:
        - name: susecve-data
          persistentVolumeClaim:
            claimName: {{ .Values.pvcName }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
      {{- end }}
      restartPolicy: {{ .Values.restartPolicy_pull }}
  backoffLimit: {{ .Values.backoffLimit }}
