apiVersion: v1
kind: Pod
metadata:
  name: openbao-server-test
  namespace: openbao
  annotations:
    "helm.sh/hook": test
spec:
  containers:
    - name: openbao-server-test
      image: quay.io/openbao/openbao:2.5.4@sha256:436eaf9778cad75507ff70ea26ace30dcbe15606e619ac3823495663d7f7c115
      imagePullPolicy: IfNotPresent
      env:
        - name: VAULT_ADDR
          value: http://openbao.openbao.svc:8200
      command:
        - /bin/sh
        - -c
        - |
          echo "Checking for sealed info in 'bao status' output"
          ATTEMPTS=10
          n=0
          until [ "$n" -ge $ATTEMPTS ]
          do
            echo "Attempt" $n...
            bao status -format yaml | grep -E '^sealed: (true|false)' && break
            n=$((n+1))
            sleep 5
          done
          if [ $n -ge $ATTEMPTS ]; then
            echo "timed out looking for sealed info in 'bao status' output"
            exit 1
          fi

          exit 0
      volumeMounts:
  volumes:
  restartPolicy: Never
