apiVersion: batch/v1
kind: Job
metadata:
  name: sync-repository
spec:
  template:
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: git-lfs
        image: alpine:3.7
        command: ["/bin/sh", "-c", "cp -r /go-cachecash/source/git-sync/* /go-cachecash/source/ && cd /go-cachecash/source/ && rm -rf ./git-sync && rm -rf ./rev*"]
        volumeMounts:
        - name: repo-data
          mountPath: /go-cachecash
        securityContext:
          allowPrivilegeEscalation: false
          runAsUser: 0
      initContainers:
      - name: git-sync
        image: k8s.gcr.io/git-sync:v3.1.6
        env:
        - name: GIT_SYNC_REPO
          value: https://github.com/bsenel/go-cachecash
        - name: GIT_SYNC_ROOT
          value: "/go-cachecash/source"
        - name: GIT_SYNC_DEST
          value: git-sync
        - name: GIT_SYNC_ONE_TIME
          value: "true"
        volumeMounts:
        - name: repo-data
          mountPath: /go-cachecash
        securityContext:
          allowPrivilegeEscalation: false
          runAsUser: 0
      restartPolicy: Never
      volumes:
      - name: repo-data
        hostPath:
          path: /mnt/cachecash
