apiVersion: batch/v1
kind: CronJob
metadata:
  name: review-stats-make-html-pages
spec:
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  concurrencyPolicy: Forbid
  activeDeadlineSeconds: 900
  startingDeadlineSeconds: 180
  schedule: "0 * * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            parent: "cronjobbuild"
        spec:
          containers:
          - name: build
            image: image-registry.openshift-image-registry.svc:5000/review-stats/builder:latest
            command: ["review-stats", "-c", "/etc/review-stats/config.cfg", "-D",
                      "make-pages", "-d", "/review-stats/"]
            env:
            - name: HOME
              value: "/tmp"
            volumeMounts:
            - name: review-stats-config
              mountPath: /etc/review-stats
              readOnly: true
            - name: build-output
              mountPath: /review-stats
              readOnly: false
          restartPolicy: Never
          startingDeadlineSeconds: 600
          volumes:
          - name: review-stats-config
            configMap:
              name: review-stats-configmap
          - name: build-output
            persistentVolumeClaim:
              claimName: openshift-{{ env_short }}-reviewstats
---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: review-stats-work-on-bugs
spec:
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  concurrencyPolicy: Forbid
  activeDeadlineSeconds: 900
  startingDeadlineSeconds: 180
  schedule: "45 0 * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            parent: "cronjobbuild"
        spec:
          containers:
          - name: build
            image: image-registry.openshift-image-registry.svc:5000/review-stats/builder:latest
{% if env == 'staging' %}
            command: ["review-stats", "-c", "/etc/review-stats/config.cfg", "-D",
                      "work-on-bugs", "-d"]
{% else %}
            command: ["review-stats", "-c", "/etc/review-stats/config.cfg", "-D",
                      "work-on-bugs"]
{% endif %}
            env:
            - name: HOME
              value: "/tmp"
            volumeMounts:
            - name: review-stats-config
              mountPath: /etc/review-stats
              readOnly: true
            - name: build-output
              mountPath: /review-stats
              readOnly: false
          restartPolicy: Never
          startingDeadlineSeconds: 600
          volumes:
          - name: review-stats-config
            configMap:
              name: review-stats-configmap
          - name: build-output
            persistentVolumeClaim:
              claimName: openshift-{{ env_short }}-reviewstats
