Skip to content

Commit 392f6ed

Browse files
dploegerDennis Ploeger
authored andcommitted
feat: Support for k9s
closes #96
1 parent 36f3d57 commit 392f6ed

5 files changed

Lines changed: 50 additions & 0 deletions

File tree

assets/feature-installer-utils.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,21 @@ function checkAndCleanVersion {
6060
echo "${VERSION}"
6161
fi
6262
}
63+
64+
# Usage: downloadFromGithub USER REPO VERSION PACKAGE_PREFIX PACKAGE_SUFFIX TARGET
65+
# Downloads a release package from github using the common architecture names
66+
# The package will be downloaded from github.com/USER/REPO/releases/VERSION/download/PACKAGE to the given TARGET file
67+
# where PACKAGE consists of PACKAGE_PREFIXARCHITECTURE.PACKAGE_SUFFIX.
68+
# Example: PACKAGE_PREFIX=krew_linux_, PACKAGE_SUFFIX=tar.gz on an arm architecture will download krew_linux_arm64.tar.gz
69+
function downloadFromGithub {
70+
USER=$1
71+
REPO=$2
72+
VERSION=$3
73+
PACKAGE_PREFIX=$4
74+
PACKAGE_SUFFIX=$5
75+
TARGET=$6
76+
77+
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
78+
PACKAGE="${PACKAGE_PREFIX}${ARCH}.${PACKAGE_SUFFIX}"
79+
execHandle "Downloading ${USER}/${REPO}@${VERSION}" curl -f -s -L "https://github.com/${USER}/${REPO}/releases/${VERSION}/download/${PACKAGE}" --output "${TARGET}"
80+
}

feature/k9s/feature.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
icon: "🐾"
2+
title: "k9s"
3+
description: "Installs [k9s](https://k9scli.io/)"
4+
configuration:
5+
- "Environment K9S_VERSION (optional): Valid k9s version to install (defaults to latest)"

feature/k9s/goss/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEBUG_k9s=yes

feature/k9s/goss/goss.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
command:
2+
k9s:
3+
exec: "/home/cloudcontrol/bin/k9s version"
4+
exit-status: 0
5+
stdout:
6+
- "Version:"

feature/k9s/install.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
. /feature-installer-utils.sh
2+
3+
if [ -n "${K9S_VERSION}" ]
4+
then
5+
K9S_VERSION=$(checkAndCleanVersion "${K9S_VERSION}")
6+
else
7+
K9S_VERSION="latest"
8+
fi
9+
10+
TEMPDIR=$(mktemp -d)
11+
cd "${TEMPDIR}" || exit
12+
13+
downloadFromGithub derailed k9s "${K9S_VERSION}" k9s_Linux_ tar.gz k9s.tar.gz
14+
15+
execHandle "Unpacking k9s" tar xzf k9s.tar.gz
16+
execHandle "Installing k9s" mv k9s /home/cloudcontrol/bin
17+
execHandle "Making k9s executable" chmod +x /home/cloudcontrol/bin/k9s
18+
19+
cd - &>/dev/null || exit
20+
rm -rf "${TEMPDIR}"

0 commit comments

Comments
 (0)