kind: Job
apiVersion: batch/v1
metadata:
  name: check-cpfs-ready
  namespace: ibm-common-services
  labels:
    job-name: check-cpfs-ready
spec:
  parallelism: 1
  completions: 1
  backoffLimit: 4
  template:
    metadata:
      labels:
        job-name: check-cpfs-ready
    spec:
      serviceAccountName: deployer
      containers:
        - name: openshift-gitops-argocd-application-controller
          image: 'quay.io/openshift/origin-cli:4.6.0'
          command:
            - /bin/bash 
            - '-c'
            - | 
              echo "start the checking by waiting few times to pods "
              sleep 300
              echo "start"
              n=$(oc get pods -n ibm-common-services --no-headers | grep -Ev 'Running|Completed'| wc -l)
              echo "boucle"
              echo $n
              while ((n > 0))
              do
                echo "Cloud Pak Foundational Services not yet installed"
                sleep 30
                n=$(oc get pods -n ibm-common-services --no-headers | grep -Ev 'Running|Completed' | wc -l)
              done
              echo "Cloud Pak Foundational Services installed"
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Never
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler