kind: Job
apiVersion: batch/v1
metadata:
  name: check-qm1-ready
  namespace: cp4i-mq-project
  labels:
    job-name: check-qm1-ready
  annotations:
    argocd.argoproj.io/sync-wave: "20"
spec:
  parallelism: 1
  completions: 1
  backoffLimit: 4
  template:
    metadata:
      labels:
        job-name: check-qm1-ready
    spec:
      serviceAccountName: deployer
      containers:
        - name: openshift-gitops-argocd-application-controller
          image: 'quay.io/openshift/origin-cli:4.8.0'
          command:
            - /bin/bash 
            - '-c'
            - | 
              echo "start the checking by waiting few times to pods "
              sleep 30
              STATUS=$(oc get queuemanager qm1 -n cp4i-mq-project -o jsonpath='{.status.phase}')
              echo "loop to monitor QM status"
              while [ $STATUS != "Running" ]; 
              do
                echo "Queue Manager is not ready"
                sleep 30
                STATUS=$(oc get queuemanager qm1 -n mq-project -o jsonpath='{.status.phase}')
              done
              echo "Queue Manager is ready"
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Never
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler