---
apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .NAME }}-backfiller
  namespace: {{ .NAMESPACE }}
spec:
  template:
    metadata:
      labels:
        app: {{ .NAME }}-backfiller
    spec:
      restartPolicy: Never
      terminationGracePeriodSeconds: 40
      serviceAccountName: pipeline
      containers:
        - name: {{ .NAME }}-backfiller
          image: {{ .IMAGE_NAME }}
          imagePullPolicy: Always
          env:
            - name: MONGODB_URI
              valueFrom:
                secretKeyRef:
                  name: mongodb
                  key: mongo-uri
            - name: MONGODB_DATABASE
              valueFrom:
                configMapKeyRef:
                  name: config
                  key: mongo-database
            - name: SNS_URL
              value: {{ .SNS_URL }}
            - name: AWS_REGION
              value: {{ .SNS_AWS_REGION }}
          command: ["/pipeline"]
          args:
            - backfiller
            - --mongo-uri
            - "$(MONGODB_URI)"
            - --mongo-database
            - "$(MONGODB_DATABASE)"
            - --aws-region
            - "{{ .SNS_AWS_REGION }}"
            - --sns-url
            - "{{ .SNS_URL }}"
            - "--start-time"
            - "2024-03-01T00:00:00Z"
            - "--page-size"
            - "1000"
            - "--requests-per-second"
            - "10000"
            - "--num-workers"
            - "10"
