Skip to content

feat: Implement asdf oasdiff plugin #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading