{{ if .Values.pim_token_update.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
  name: pim-token-update
spec:
  schedule: "{{ .Values.pim_token_update.schedule }}"
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 86400
      backoffLimit: 1
      template:
        spec:
          imagePullSecrets:
          - name: regcred
          containers:
          - name: model
            image: goalprofit/pim-token-update:{{ .Values.pim_token_update.version }}
            imagePullPolicy: Always
            env:
              - name: PIM_API_URL
                value: {{ .Values.pim_api_url }}
              - name: SERVICE_LOGIN
                valueFrom:
                  secretKeyRef:
                    name: secret-service
                    key: username
                    optional: false
              - name: SERVICE_PASSWORD
                valueFrom:
                  secretKeyRef:
                    name: secret-service
                    key: password
                    optional: false
          restartPolicy: Never
          {{ include "app.affinity" . | nindent 10}}
{{ end }}