apiVersion: v1
kind: Pod
metadata:
  annotations:
    helm.sh/hook: test
  name: RELEASE-NAME-server-test
  namespace: default
spec:
  containers:
  - command:
    - /bin/sh
    - -c
    - |
      echo "Checking for sealed info in 'vault status' output"
      ATTEMPTS=10
      n=0
      until [ "$n" -ge $ATTEMPTS ]
      do
        echo "Attempt" $n...
        vault 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 'vault status' output"
        exit 1
      fi

      exit 0
    env:
    - name: VAULT_ADDR
      value: http://RELEASE-NAME-vault.default.svc:8200
    image: releases-docker.jfrog.io/hashicorp/vault:1.8.3
    imagePullPolicy: IfNotPresent
    name: RELEASE-NAME-server-test
  restartPolicy: Never
