#!/bin/sh
set -eu
url=
output=
while [ "$#" -gt 0 ]; do
  case "$1" in
    -o) output=$2; shift 2 ;;
    https://*) url=$1; shift ;;
    *) shift ;;
  esac
done
case "$url" in
  "https://github.com/nikhilsbhat/helm-diff-summary/releases/download/v${TEST_PLUGIN_VERSION}/"*) ;;
  *) echo "Unexpected download URL: $url" >&2; exit 1 ;;
esac
if [ "${TEST_DOWNLOAD_FAIL:-0}" = 1 ]; then
  exit 22
fi
cp "$TEST_PLUGIN_RELEASE/${url##*/}" "$output"
