Skip to content

Commit

Permalink
Add ARM64 support for the Tanzu CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Khouzam <marc.khouzam@broadcom.com>
  • Loading branch information
marckhouzam committed Jun 22, 2024
1 parent ff607ff commit 7df4a82
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ asdf install bosh 7.0.0
asdf global bosh 7.0.0
```

To manually install use the following, where tool name is one of the support tools listed above:
To manually install use the following, where tool name is one of the supported tools listed above:
```
asdf plugin-add <tool name> https://github.com/vmware-tanzu/tanzu-plug-in-for-asdf.git
```
Expand Down
7 changes: 4 additions & 3 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ set -euo pipefail
readonly script_dir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly file_name="$(basename "$(dirname "${script_dir}")")"
readonly os=$(uname -s |awk '{print tolower($0)}')
readonly arch=$(a=$(uname -m) && ([ $a = aarch64 ] || [ $a = arm64 ]) && printf arm64 || printf amd64)
readonly version=$ASDF_INSTALL_VERSION
readonly asdf_download_path=$ASDF_DOWNLOAD_PATH
readonly download_dir="$(mktemp -d -t "asdf_${file_name}_XXXXXXXX")"
trap 'rm -rf "${download_dir}"' EXIT

. "${script_dir}/../products.inc.sh" "${file_name}" "${version}" "${os}"
. "${script_dir}/../products.inc.sh" "${file_name}" "${version}" "${os}" "${arch}"

if [[ ${MISSING_PRODUCTS[*]} =~ "${file_name}_${os}" ]]; then
echo -e "\nError message: ${file_name} is not available for OS type ${os}\n" >&2
if [[ ${MISSING_PRODUCTS[*]} =~ "${file_name}_${os}_${arch}" ]]; then
echo -e "\nError message: ${file_name} is not available for OS type ${os}_${arch}\n" >&2
exit 1
fi

Expand Down
14 changes: 11 additions & 3 deletions products.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ setEnv() {
local product="${1:-}"
local v="${2:-}"
local o="${3:-}"
local a="${4:-}"

# To add a product create a case statement matching the file name and add variables as follows
# REPO_SLUG
Expand Down Expand Up @@ -78,8 +79,13 @@ setEnv() {
VERSION_COMMAND='version'
;;
tanzu)
# Tanzu CLI only started supporting ARM64 natively for darwin with version 1.1.0*
# we therefore use the AMD64 version for older versions
if [[ "${o}" == "darwin" && "${v}" < "1.1.0" ]]; then
a="amd64"
fi
REPO_SLUG='vmware-tanzu/tanzu-cli'
PRIMARY_GIT_TEMPLATE="v${v}/tanzu-cli-${o}-amd64.tar.gz"
PRIMARY_GIT_TEMPLATE="v${v}/tanzu-cli-${o}-${a}.tar.gz"
SECONDARY_GIT_TEMPLATE=""
VERSION_COMMAND='version' #| grep version | sed -n -e "s/^.*version: v//p"
;;
Expand All @@ -95,9 +101,11 @@ setEnv() {
;;
esac

# MISSING_PRODUCTS is used to highlight products that aren't available for an OS type
# MISSING_PRODUCTS is used to highlight products that aren't available for an OS_ARCH type
MISSING_PRODUCTS=(
"bbr-s3-config-validator_darwin"
"bbr-s3-config-validator_darwin_amd64"
"bbr-s3-config-validator_darwin_arm64"
"tanzu_linux_arm64"
)

declare -rx REPO_SLUG GIT_FILE_NAME_TEMPLATE VERSION_COMMAND
Expand Down

0 comments on commit 7df4a82

Please sign in to comment.