if [ -z "$1" ]; then
    echo "Usage: source get-taiko-vars.sh RELEASE_NAME"
    return 1
else
    release="$1"
fi

tempfile=$(mktemp)

helm get values "$release" -o json > "$tempfile"

# Set this to true and add SSO details 
# if you want to use OIDC-based login in your tests
export USE_SSO_LOGIN=false
export SSO_USERNAME=admin@example.com
export SSO_USER_PW=""

# Nextcloud admin username
export NEXTCLOUD_ADMIN_USERNAME=admin

# Nextcloud admin password imported from the helm values.
NEXTCLOUD_ADMIN_PASSWORD=$(jq -r '.nextcloud.nextcloud.password' < "$tempfile")
export NEXTCLOUD_ADMIN_PASSWORD

NEXTCLOUD_URL=$(jq -r '.nextcloud.nextcloud.host' < "$tempfile")
export NEXTCLOUD_URL

ONLYOFFICE_URL=$(jq -r '.onlyoffice.server_name' < "$tempfile")
export ONLYOFFICE_URL

# Comma-separated list of applications to test. Check if taiko-tests/test.js
# supports testing your application if you want to add apps here.
export INSTALLED_APPS=""

rm "$tempfile"

echo "Imported values from Helm."