Skip to content
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

feat: Support for Tanzucli #156

Merged
merged 2 commits into from
Aug 13, 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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Following features and tools are supported:
* 👟 Run
* 🔑 sops
* 📜 Stern
* ⎔ Tanzu CLI
* 🌏 Terraform
* 🐗 Terragrunt
* 🕰 Timezone configuration
Expand Down Expand Up @@ -69,6 +70,7 @@ Following features and tools are supported:
* [Run](#run)
* [sops](#sops)
* [Stern](#stern)
* [Tanzu CLI](#tanzucli)
* [Terraform](#terraform)
* [Terragrunt](#terragrunt)
* [Timezone configuration](#timezone)
Expand Down Expand Up @@ -577,6 +579,16 @@ Installs [stern](https://github.com/stern/stern), a multi pod and container log
* DEBUG_stern: Debug this feature
* Environment STERN_VERSION (required): Valid Stern version (e.g. 1.21.0)

### <a id="tanzucli"></a> Tanzu CLI

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

#### Configuration

* USE_tanzucli: Enable this feature
ThomasMinor marked this conversation as resolved.
Show resolved Hide resolved
* DEBUG_tanzucli: Debug this feature
* Environment TANZU_CLI_VERSION: Tanzu CLI version to install (required)

### <a id="terraform"></a> Terraform

Installs and configures [Terraform](https://terraform.io)
Expand Down
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