apiVersion: batch/v1
kind: Job
metadata:
  name: update-modules
  annotations:
    argocd.argoproj.io/hook: Sync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      restartPolicy: Never
      initContainers:
      - name: modules-installer
        image: docker.pkg.github.com/virtocommerce/vc-deploy-containers/platform-installer:v3
        env:
        - name: MODULES_CONFIG
          valueFrom:
            configMapKeyRef:
              name: modules-config
              key: modules.json
        command:
          - "/bin/sh"
          - "-c"
        args:
          - "echo START INIT $(date +%Y-%m-%d-%H-%M-%S)
          && python3 install-modules.py \"$MODULES_CONFIG\" /mnt/Modules/*"
        volumeMounts:
        - name: modules-volume
          mountPath: /mnt/Modules
          readOnly: false
      containers:
      - name: sync
        image: curlimages/curl
        command:
          - "curl"
          - "-d"
          - "{\"label\":\"saas-template\"}"
          - "-H"
          - "Content-Type: application/json"
          - "-X"
          - "POST"
          - "http://webhook-eventsource-svc.argo.svc.cluster.local:12000/saas-postsync"
      volumes:
      - name: modules-volume
        persistentVolumeClaim:
          claimName: modules-volume
  backoffLimit: 2