Skip to content

Commit

Permalink
update download url
Browse files Browse the repository at this point in the history
  • Loading branch information
nsaputro-shell committed Jan 3, 2024
1 parent 79bdf22 commit b48cbda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 10 additions & 11 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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() {
Expand All @@ -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."
Expand Down

0 comments on commit b48cbda

Please sign in to comment.