apiVersion: batch/v1
kind: CronJob
metadata:
  name: "{{ .Chart.Name }}-{{ .Chart.Version }}"
  namespace: "{{ .Values.global.namespace }}"
  labels:
    app: "{{ .Chart.Name }}"
    version: "{{ .Chart.Version }}"
spec:
  schedule: "10,51 6,11,12,13,17,18 * * *"
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 1
  jobTemplate:
    spec:
      completions: 1
      template:
        spec:
          serviceAccountName: "{{ .Values.global.serviceAccountNames.importer}}"
          containers:
          - name: install-tekton-catalog
            image: registry.access.redhat.com/ubi8/toolbox
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - |-
              ls -la /catalog
              cat /catalog/config/values.yaml; 
              /catalog/importer/{{ .Chart.Name }}.sh /catalog/config/values.yaml;
            volumeMounts:
            - name: script
              mountPath: "/catalog/importer/"
            - name: values-catalog-config
              mountPath: "/catalog/config/"
          volumes:
          - name: script
            configMap:
              name: "{{ .Chart.Name }}-script-{{ .Chart.Version }}"
              defaultMode: 0777
          - name: values-catalog-config
            configMap:
              name: "{{ .Chart.Name }}-customer-config-{{ .Chart.Version }}"
              defaultMode: 0777
          restartPolicy: OnFailure
