-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Installation issues fix * Installation issues fix * Installation issues fix * Installation issues fix * Installation issues fix * Installation issues fix
- Loading branch information
1 parent
cebbf44
commit bc20e00
Showing
3 changed files
with
68 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,25 @@ | ||
name: Main workflow | ||
name: Test Plugin | ||
|
||
on: | ||
pull_request: | ||
push: | ||
schedule: | ||
- cron: 0 0 * * 5 | ||
- cron: 0 1 * * MON | ||
|
||
jobs: | ||
plugin_test: | ||
test-plugin: | ||
name: Test Plugin | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
tool: | ||
- boundary | ||
- consul | ||
- levant | ||
- nomad | ||
- packer | ||
- sentinel | ||
- serf | ||
- terraform | ||
- terraform-ls | ||
- vault | ||
- waypoint | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: asdf_plugin_test | ||
uses: asdf-vm/actions/plugin-test@v1 | ||
- uses: asdf-vm/actions/plugin-test@v2 | ||
with: | ||
command: ${{ matrix.tool }} version | ||
plugin: ${{ matrix.tool }} | ||
|
||
test: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup asdf | ||
uses: asdf-vm/actions/setup@v1 | ||
|
||
- name: Install bats-core | ||
run: brew install --build-from-source bats-core | ||
|
||
- name: Test plugin | ||
run: make test | ||
env: | ||
GITHUB_API_TOKEN: ${{ github.token }} | ||
|
||
lint: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install ShellCheck | ||
run: brew install shellcheck | ||
|
||
- name: Run ShellCheck | ||
run: make lint | ||
|
||
format: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install shfmt | ||
run: brew install shfmt | ||
|
||
- name: Run shfmt | ||
run: make fmt-check | ||
command: crictl --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,49 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
local_version="$1" | ||
install_path="$2" | ||
|
||
os_name="$(uname -s)" | ||
case "${os_name}" in | ||
Linux*) os=linux;; | ||
Darwin*) os=darwin;; | ||
CYGWIN*) os=windows;; | ||
MINGW*) os=windows;; | ||
*) echo "unknown OS"; exit 1;; | ||
esac | ||
|
||
case "$(uname -m)" in | ||
x86_64*) arch=amd64;; | ||
arm64*) arch=arm64;; | ||
*) echo "unknown architecture"; exit 1;; | ||
esac | ||
|
||
tmpdir="$(mktemp -d)" | ||
|
||
pushd "$tmpdir" >/dev/null | ||
|
||
binary_url="https://github.com/kubernetes-sigs/cri-tools/releases/download/v${local_version}/crictl-v${local_version}-${os}-${arch}.tar.gz" | ||
curl -L -o "crictl.tar.gz" "$binary_url" | ||
|
||
tar xzf "crictl.tar.gz" | ||
|
||
mv "crictl" "$install_path/bin/crictl" | ||
|
||
popd >/dev/null | ||
|
||
rm -rf "$tmpdir" | ||
set -e | ||
set -o pipefail | ||
|
||
install_crictl() { | ||
local install_type=$1 | ||
local version=$2 | ||
local install_path=$3 | ||
local platform="$(uname | tr '[:upper:]' '[:lower:]')-amd64" | ||
local bin_install_path="$install_path/bin" | ||
local binary_path="$bin_install_path/crictl" | ||
local download_url=$(get_download_url $version $platform) | ||
|
||
if [ "$TMPDIR" = "" ]; then | ||
local tmp_download_dir=$(mktemp -d -t crictl_XXXXXX) | ||
else | ||
local tmp_download_dir=$TMPDIR | ||
fi | ||
|
||
local download_path="$tmp_download_dir/$(get_filename $version $platform)" | ||
|
||
echo "Downloading crictl from ${download_url} to ${download_path}" | ||
curl -Lo $download_path $download_url | ||
|
||
echo "Creating bin directory" | ||
mkdir -p "${bin_install_path}" | ||
|
||
echo "Cleaning previous binaries" | ||
rm -f $binary_path 2>/dev/null || true | ||
|
||
echo "Copying binary" | ||
tar -zxf ${download_path} --directory $tmp_download_dir | ||
cp ${tmp_download_dir}/crictl ${bin_install_path} | ||
chmod +x ${binary_path} | ||
} | ||
|
||
get_filename() { | ||
echo "crictl-v${1}-${2}.tar.gz" | ||
} | ||
|
||
get_download_url() { | ||
local version="$1" | ||
local platform="$2" | ||
local filename="$(get_filename $version $platform)" | ||
echo "https://github.com/kubernetes-sigs/cri-tools/releases/download/v${version}/${filename}" | ||
} | ||
|
||
install_crictl $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
curl -s "https://api.github.com/repos/kubernetes-sigs/cri-tools/releases" | | ||
grep '"tag_name":' | | ||
sed -E 's/.*"v([^"]+)".*/\1/' | | ||
sort -V | ||
release_path=https://api.github.com/repos/kubernetes-sigs/cri-tools/releases | ||
cmd="curl -s" | ||
if [ -n "$GITHUB_API_TOKEN" ]; then | ||
cmd="$cmd -H 'Authorization: token $GITHUB_API_TOKEN'" | ||
fi | ||
cmd="$cmd $release_path" | ||
|
||
function sort_versions() { | ||
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \ | ||
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' | ||
} | ||
|
||
versions=$(eval $cmd | grep -oE "tag_name\": *\"v.*.{1,15}\"," | sed 's/tag_name\": *\"v//;s/\",//' | sort_versions) | ||
echo $versions |