Skip to content

Commit

Permalink
fix: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kvendingoldo committed Apr 30, 2024
1 parent 95d4b6d commit ada5810
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: asdf-vm/actions/install@v3

- run: scripts/lint.bash
- run: scripts/lint.sh

actionlint:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "${current_script_path}")")

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

mkdir -p "${ASDF_DOWNLOAD_PATH}"

Expand Down
4 changes: 2 additions & 2 deletions bin/help.links
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "${current_script_path}")")

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

cat <<EOF
- official: https://github.com/tofuutils/tenv
Expand Down
4 changes: 2 additions & 2 deletions bin/help.overview
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -euo pipefail
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "${current_script_path}")")

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

cat <<EOF
tenv: a versatile version manager for OpenTofu, Terraform and Terragrunt, written in Go
Expand Down
4 changes: 2 additions & 2 deletions 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
source "${plugin_dir}/lib/utils.bash"
# shellcheck source=./lib/utils.sh
source "${plugin_dir}/lib/utils.sh"

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

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

curl_opts=(-sI)

Expand Down
4 changes: 2 additions & 2 deletions 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
source "${plugin_dir}/lib/utils.bash"
# shellcheck source=./lib/utils.sh
source "${plugin_dir}/lib/utils.sh"

list_all_versions | sort_versions | xargs echo
43 changes: 12 additions & 31 deletions lib/utils.bash → lib/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ list_all_versions() {
get_platform() {
local -r kernel="$(uname -s)"
if [[ ${OSTYPE} == "msys" || ${kernel} == "CYGWIN"* || ${kernel} == "MINGW"* ]]; then
echo windows
echo Windows
else
uname | tr '[:upper:]' '[:lower:]'
uname
fi
}

Expand Down Expand Up @@ -70,10 +70,10 @@ download_release() {
local -r platform="$(get_platform)"
local -r arch="$(get_arch)"

url="$GH_REPO/releases/download/v${version}/${TOOL_BIN_NAME}_${version}_${platform}_${arch}.tar.gz"
url="$GH_REPO/releases/download/v${version}/${TOOL_BIN_NAME}_v${version}_${platform}_${arch}.tar.gz"

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

# Extract contents of zip file into the download directory
tar -xzf "${filename}" -C "${ASDF_DOWNLOAD_PATH}" || fail "Could not extract ${filename}"
Expand Down Expand Up @@ -108,34 +108,15 @@ install_version() {
rm "$(get_release_file)"
) || (
rm -rf "$install_path"
fail "An error occurred while installing $TOOL_NAME $version."
fail "An error occurred while installing ${TOOL_NAME} ${version}."
)
}

verify() {
local -r version="$1"
local -r download_path="$2"
local -r checksum_file="${TOOL_BIN_NAME}_${version}_SHA256SUMS"
local -r signature_file="${checksum_file}.sig"
local -r cert_file="${checksum_file}.pem"
local -r cert_identity="https://github\.com/tofuutils/tenv/\.github/workflows/release\.yml@refs/(heads|tags)/(main|v1\..+)"
local -r cert_oidc_issuer="https://token.actions.githubusercontent.com"

baseURL="$GH_REPO/releases/download/v${version}"
local files=("$checksum_file" "$signature_file" "$cert_file")
echo "* Downloading signature files ..."
for file in "${files[@]}"; do
curl "${curl_opts[@]}" -o "${download_path}/${file}" "${baseURL}/${file}" || fail "Could not download ${baseURL}/${file}"
done

if ! (
cosign verify-blob --signature "${download_path}/${signature_file}" \
--certificate "${download_path}/${cert_file}" \
--certificate-identity-regexp="${cert_identity}" \
--certificate-oidc-issuer="${cert_oidc_issuer}" \
"${download_path}/${checksum_file}"
); then
echo "signature verification failed" >&2
return 1
fi
local -r version="${1}"
local -r download_path="${2}"
local -r checksum_file="${TOOL_BIN_NAME}_${version}_checksums.txt"

baseURL="${GH_REPO}/releases/download/v${version}"
local files=("$checksum_file")
}
File renamed without changes.
File renamed without changes.

0 comments on commit ada5810

Please sign in to comment.