{{ if .Values.retail_restart.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
  name: retail-restart
spec:
  schedule: "{{ .Values.retail_restart.schedule }}"
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 36000
      backoffLimit: 1

      template:
        spec:
          restartPolicy: Never
          containers:
          - name: retail-restart
            image: docker.io/goalprofit/env:1.1
            imagePullPolicy: Always
            args:
              - bash
              - -c
              - kubectl -n $(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) rollout restart statefulset retail
            env:
    {{ if .Values.local_user_id }}
            - name: LOCAL_USER_ID
              value: "{{.Values.local_user_id}}"
    {{ end }}
    {{ if .Values.local_user_name }}
            - name: LOCAL_USER_NAME
              value: "{{.Values.local_user_name}}"
    {{ end }}

          imagePullSecrets:
          - name: regcred
      {{ include "app.affinity" . | nindent 6}}
{{ end }}