Skip to content

Commit

Permalink
feat: Support for Tanzucli
Browse files Browse the repository at this point in the history
Includes fixes to the feature-installer-utils that came up during development
  • Loading branch information
dploeger committed Aug 6, 2024
1 parent 7f7374a commit a25a1cf
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
5 changes: 3 additions & 2 deletions assets/feature-installer-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function downloadFromGithub {
TARGET=$6

ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
PACKAGE="${PACKAGE_PREFIX}${ARCH}.${PACKAGE_SUFFIX}"
execHandle "Downloading ${USER}/${REPO}@${VERSION}" curl -f -s -L "https://github.com/${USER}/${REPO}/releases/${VERSION}/download/${PACKAGE}" --output "${TARGET}"
PACKAGE="${PACKAGE_PREFIX}${ARCH}${PACKAGE_SUFFIX}"

execHandle "Downloading ${USER}/${REPO}@${VERSION}" curl -f -s -L "https://github.com/${USER}/${REPO}/releases/download/${VERSION}/${PACKAGE}" --output "${TARGET}"
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Setup required environment for test
export EXAMPLE_ENVIRONMENT=something
EXAMPLE_ENVIRONMENT=something
2 changes: 1 addition & 1 deletion feature/k9s/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
TEMPDIR=$(mktemp -d)
cd "${TEMPDIR}" || exit

downloadFromGithub derailed k9s "${K9S_VERSION}" k9s_Linux_ tar.gz k9s.tar.gz
downloadFromGithub derailed k9s "${K9S_VERSION}" k9s_Linux_ .tar.gz k9s.tar.gz

execHandle "Unpacking k9s" tar xzf k9s.tar.gz
execHandle "Installing k9s" mv k9s /home/cloudcontrol/bin
Expand Down
9 changes: 9 additions & 0 deletions feature/tanzucli/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
icon: ""

title: "Tanzu CLI"

description: "Installs the [Tanzu CLI](https://github.com/vmware-tanzu/tanzu-cli)"

configuration:
- |
Environment TANZU_CLI_VERSION: Tanzu CLI version to install (required)
1 change: 1 addition & 0 deletions feature/tanzucli/goss/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TANZUCLI_VERSION=1.4.0
6 changes: 6 additions & 0 deletions feature/tanzucli/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
test:
exec: "/home/cloudcontrol/bin/tanzu-cli version"
stdout:
- "version: v1.4.0"
exit-status: 0
20 changes: 20 additions & 0 deletions feature/tanzucli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
. /feature-installer-utils.sh

if [ -n "${TANZUCLI_VERSION}" ]
then
prepare
VERSION=$(checkAndCleanVersion "${TANZUCLI_VERSION}")
SUFFIX=".tar.gz"
if [ "$(getPlatform)" = "arm64" ]
then
SUFFIX="-unstable.tar.gz"
fi
downloadFromGithub vmware-tanzu tanzu-cli "v${VERSION}" tanzu-cli-linux- "${SUFFIX}" tanzu-cli-linux.tar.gz
execHandle "Extracting tanzu cli" tar xzf tanzu-cli-linux.tar.gz
execHandle "Installing tanzu cli" mv "${VERSION}"/tanzu-cli* "${BINPATH}/tanzu-cli"
execHandle "Making tanzu cli executable" chmod +x "${BINPATH}/tanzu-cli"
cleanup
else
echo "The tanzucli feature requires a version set using TANZUCLI_VERSION. See https://github.com/vmware-tanzu/tanzu-cli/releases for valid versions"
exit 1
fi

0 comments on commit a25a1cf

Please sign in to comment.