diff --git a/README.md b/README.md index 40022d2..7577e3f 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,7 @@ # Dependencies -**TODO: adapt this section** - - `bash`, `curl`, `tar`, and [POSIX utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html). -- `SOME_ENV_VAR`: set this environment variable in your shell config to load the correct version of tool x. # Install diff --git a/lib/utils.bash b/lib/utils.bash index f7e5491..bbf75ce 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -2,7 +2,6 @@ set -euo pipefail -# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for monaco. GH_REPO="https://github.com/Dynatrace/dynatrace-configuration-as-code" TOOL_NAME="monaco" TOOL_TEST="monaco version" @@ -14,7 +13,6 @@ fail() { curl_opts=(-fsSL) -# NOTE: You might want to remove this if monaco is not hosted on GitHub releases. if [ -n "${GITHUB_API_TOKEN:-}" ]; then curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN") fi @@ -27,25 +25,27 @@ sort_versions() { list_github_tags() { git ls-remote --tags --refs "$GH_REPO" | grep -o 'refs/tags/.*' | cut -d/ -f3- | - sed 's/^v//' # NOTE: You might want to adapt this sed to remove non-version strings from tags + sed 's/^v//' } list_all_versions() { - # TODO: Adapt this. By default we simply list the tag names from GitHub releases. - # Change this function if monaco has other means of determining installable versions. list_github_tags } download_release() { - local version filename url - version="$1" - filename="$2" + local version="$1" + local filename="$2" + local platform="$(get_platform)" + local arch="$(get_arch)" - # TODO: Adapt the release URL convention for monaco - url="$GH_REPO/archive/v${version}.tar.gz" + local url="$GH_REPO/releases/download/v${version}/monaco-${arch}-${platform}" + + echo $url echo "* Downloading $TOOL_NAME release $version..." curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url" + + chmod +x "$filename" } install_version() { @@ -61,7 +61,6 @@ install_version() { mkdir -p "$install_path" cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path" - # TODO: Assert monaco executable exists. local tool_cmd tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)" test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."