{{ if .Values.sync.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sync
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sync
  template:
    metadata:
      name: sync
      labels:
        app: sync
    spec:
      containers:
      - name: sync
        image: docker.io/goalprofit/env:1.1
        imagePullPolicy: Always
        args:
          - bash
          - -c
          - |
            while true
            do
            python3 sync.py
            sleep 10m &
            wait $!
            done
        workingDir: /data
        volumeMounts:
        - mountPath: /data
          name: data
        - mountPath: /home
          name: home
        env:
        - name: TZ
          value: {{ .Values.timeZone }}
{{ 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

      volumes:
      - name: data
        hostPath:
          path: /data/{{.Values.customer}}/in/ext/sftp/
          type: Directory

      - name: home
        hostPath:
          path: /home
          type: Directory
      {{ include "app.affinity" . | nindent 6}}
{{ end }}