apiVersion: batch/v1
kind: Job
metadata:
  name: pruner-configuration
  namespace: openshift-pipelines
  annotations:
    argocd.argoproj.io/hook: PostSync
spec:
  template:
    spec:
      containers:
        - image: registry.redhat.io/openshift4/ose-cli:v4.9
          command:
            - /bin/bash
            - -c
            - |
              echo "Waiting for TektonConfig config to be present"
              until oc get TektonConfig config
              do
                sleep $SLEEP;
              done
 
              echo "Patching TektonConfig config patameters"
              oc patch TektonConfig config -p '{"spec":{"pruner":{"keep": 10, "schedule": "0/10 * * * *"}}}' --type=merge
          imagePullPolicy: Always
          name: patch-tekton-config
          env:
            - name: SLEEP
              value: "5"
      dnsPolicy: ClusterFirst
      restartPolicy: OnFailure
      terminationGracePeriodSeconds: 30
      serviceAccount: patch-tekton-config
      serviceAccountName: patch-tekton-config
