apiVersion: batch/v1
kind: Job
metadata:
  name: suspend-rollouts
  annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      serviceAccountName: sa-rollouts
      restartPolicy: Never
      containers:
      - name: argo-rollout
        image: kkisilevsky/argo-kubectl-rollouts:latest
        command:
          - "bin/bash"
          - "-c"
        args:
          - "kubectl get rollout -n dev -l template=saas-template | awk '{ print $1 }' | tail -n+2 > rollouts
          && while read p; do kubectl argo rollouts pause -n dev $p; done < rollouts"
  backoffLimit: 2