Skip to content

Commit

Permalink
Merge pull request #1 from jesmarla/main
Browse files Browse the repository at this point in the history
feat: Implement asdf oasdiff plugin
  • Loading branch information
reuvenharrison authored Aug 20, 2024
2 parents 02a6921 + 4a609a1 commit 985afbe
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ jobs:
uses: asdf-vm/actions/plugin-test@v2
with:
command: oasdiff --help
- name: asdf_plugin_test_1_10_23
uses: asdf-vm/actions/plugin-test@v2
with:
command: oasdiff --version
version: 1.10.23
4 changes: 2 additions & 2 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=../lib/utils.bash
# shellcheck source=lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"
Expand All @@ -17,7 +17,7 @@ release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME-$ASDF_INSTALL_VERSION.tar.gz"
download_release "$ASDF_INSTALL_VERSION" "$release_file"

# Extract contents of tar.gz file into the download directory
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" --strip-components=1 || fail "Could not extract $release_file"
tar -xzf "$release_file" -C "$ASDF_DOWNLOAD_PATH" || fail "Could not extract $release_file"

# Remove the tar.gz file since we don't need to keep it
rm "$release_file"
2 changes: 1 addition & 1 deletion bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=../lib/utils.bash
# shellcheck source=lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
2 changes: 1 addition & 1 deletion bin/latest-stable
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=../lib/utils.bash
# shellcheck source=lib/utils.bash
. "${plugin_dir}/lib/utils.bash"

curl_opts=(-sI)
Expand Down
2 changes: 1 addition & 1 deletion bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=../lib/utils.bash
# shellcheck source=lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

list_all_versions | sort_versions | xargs echo
26 changes: 23 additions & 3 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

]GH_REPO="https://github.com/tufin/oasdiff"
GH_REPO="https://github.com/Tufin/oasdiff"
TOOL_NAME="oasdiff"
TOOL_TEST="oasdiff --help"

Expand Down Expand Up @@ -36,17 +36,37 @@ list_all_versions() {
}

download_release() {
local version filename url
local version filename url platform
version="$1"
filename="$2"
platform=$(get_platform "$version")

# TODO: Adapt the release URL convention for oasdiff
url="$GH_REPO/archive/v${version}.tar.gz"
url="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${version}_$platform.tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
}

get_platform() {
local version=$1

case $(uname) in
#Linux OS
Linux)
if [ "$(uname -m)" = "aarch64" ]; then
echo "linux_arm64"
else
echo "linux_amd64"
fi
;;
#Mac OS
Darwin)
echo "darwin_all"
;;
esac
}

install_version() {
local install_type="$1"
local version="$2"
Expand Down

0 comments on commit 985afbe

Please sign in to comment.