#!/usr/bin/env bash
sub="${1:-}"
case "$sub" in
  whoami) echo "User: jessea123" ;;
  run)
    if printf '%s ' "$@" | grep -q 'get-root-ca'; then
      printf '{"vault/0":{"output":"-----BEGIN CERTIFICATE-----\\nMIIBfakepem0123\\n-----END CERTIFICATE-----"}}\n'
    elif printf '%s ' "$@" | grep -q 'get-admin-password'; then
      if [ "${PASS_EMPTY:-0}" = 1 ]; then printf '{"keystone/0":{"output":{}}}\n'
      else printf '{"keystone/0":{"admin-password":"%s"}}\n' "${ADMIN_PASS_FIX:-s3cr3t-pw}"; fi
    fi ;;
esac
