apiVersion: batch/v1
kind: CronJob
metadata:
  annotations: {}
  labels:
    app.kubernetes.io/managed-by: commodore
    app.kubernetes.io/name: appuio-cloud-reporting
    app.kubernetes.io/part-of: syn
    name: check-missing
  name: check-missing
  namespace: appuio-cloud-reporting
spec:
  failedJobsHistoryLimit: 3
  jobTemplate:
    metadata:
      labels:
        app.kubernetes.io/managed-by: commodore
        app.kubernetes.io/name: appuio-cloud-reporting
        app.kubernetes.io/part-of: syn
        cron-job-name: check-missing
    spec:
      template:
        metadata:
          labels:
            app.kubernetes.io/managed-by: commodore
            app.kubernetes.io/name: appuio-cloud-reporting
            app.kubernetes.io/part-of: syn
        spec:
          containers:
            - args:
                - check_missing
              env:
                - name: password
                  valueFrom:
                    secretKeyRef:
                      key: password
                      name: reporting-db
                - name: username
                  valueFrom:
                    secretKeyRef:
                      key: username
                      name: reporting-db
                - name: ACR_DB_URL
                  value: postgres://$(username):$(password)@db.example.com:5432/appuio-cloud-reporting?
                - name: OA_DB_URL
                  value: $(ACR_DB_URL)
              image: ghcr.io/appuio/appuio-cloud-reporting:v0.5.0
              name: check-missing
              resources: {}
          initContainers:
            - args:
                - migrate
                - --show-pending
              env:
                - name: password
                  valueFrom:
                    secretKeyRef:
                      key: password
                      name: reporting-db
                - name: username
                  valueFrom:
                    secretKeyRef:
                      key: username
                      name: reporting-db
                - name: ACR_DB_URL
                  value: postgres://$(username):$(password)@db.example.com:5432/appuio-cloud-reporting?
                - name: OA_DB_URL
                  value: $(ACR_DB_URL)
              image: ghcr.io/appuio/appuio-cloud-reporting:v0.5.0
              name: check-migration
            - args:
                - sync
              env:
                - name: password
                  valueFrom:
                    secretKeyRef:
                      key: password
                      name: reporting-db
                - name: username
                  valueFrom:
                    secretKeyRef:
                      key: username
                      name: reporting-db
                - name: ACR_DB_URL
                  value: postgres://$(username):$(password)@db.example.com:5432/appuio-cloud-reporting?
                - name: OA_DB_URL
                  value: $(ACR_DB_URL)
                - name: OA_ODOO_URL
                  valueFrom:
                    secretKeyRef:
                      key: url
                      name: erp-url
              image: ghcr.io/vshn/appuio-odoo-adapter:v1.2.1
              name: sync-categories
          restartPolicy: OnFailure
  schedule: 30 8-14 * * *
  successfulJobsHistoryLimit: 3
