Skip to content

Commit

Permalink
feat: Support for k9s
Browse files Browse the repository at this point in the history
closes #96
  • Loading branch information
dploeger committed Dec 29, 2023
1 parent 02155ce commit 7ffea8a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
18 changes: 18 additions & 0 deletions assets/feature-installer-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,21 @@ function checkAndCleanVersion {
echo "${VERSION}"
fi
}

# Usage: downloadFromGithub USER REPO VERSION PACKAGE_PREFIX PACKAGE_SUFFIX TARGET
# Downloads a release package from github using the common architecture names
# The package will be downloaded from github.com/USER/REPO/releases/VERSION/download/PACKAGE to the given TARGET file
# where PACKAGE consists of PACKAGE_PREFIXARCHITECTURE.PACKAGE_SUFFIX.
# Example: PACKAGE_PREFIX=krew_linux_, PACKAGE_SUFFIX=tar.gz on an arm architecture will download krew_linux_arm64.tar.gz
function downloadFromGithub {
USER=$1
REPO=$2
VERSION=$3
PACKAGE_PREFIX=$4
PACKAGE_SUFFIX=$5
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}"
}
5 changes: 5 additions & 0 deletions feature/k9s/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
icon: "🐾"
title: "k9s"
description: "Installs [k9s](https://k9scli.io/)"
configuration:
- "Environment K9S_VERSION (optional): Valid k9s version to install (defaults to latest)"
1 change: 1 addition & 0 deletions feature/k9s/goss/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEBUG_k9s=yes
6 changes: 6 additions & 0 deletions feature/k9s/goss/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
k9s:
exec: "/home/cloudcontrol/bin/k9s version"
exit-status: 0
stdout:
- "Version:"
20 changes: 20 additions & 0 deletions feature/k9s/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
. /feature-installer-utils.sh

if [ -n "${K9S_VERSION}" ]
then
K9S_VERSION=$(checkAndCleanVersion "${K9S_VERSION}")
else
K9S_VERSION="latest"
fi

TEMPDIR=$(mktemp -d)
cd "${TEMPDIR}" || exit

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
execHandle "Making k9s executable" chmod +x /home/cloudcontrol/bin/k9s

cd - &>/dev/null || exit
rm -rf "${TEMPDIR}"

0 comments on commit 7ffea8a

Please sign in to comment.