Skip to content

Commit

Permalink
Merge pull request #43 from rio/fix-k9s-checksum-filename-change
Browse files Browse the repository at this point in the history
fix(k9s): compensate for checksum filename change
  • Loading branch information
rio authored Nov 7, 2023
2 parents 470d719 + 91c269f commit 4a3f581
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/k9s/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "k9s",
"id": "k9s",
"version": "1.1.3",
"version": "1.1.4",
"description": "K9s provides a terminal UI to interact with your Kubernetes clusters. The aim of this project is to make it easier to navigate, observe and manage your applications in the wild. K9s continually watches Kubernetes for changes and offers subsequent commands to interact with your observed resources.",
"options": {
"version": {
"type": "string",
"default": "0.27.4",
"default": "latest",
"description": "Version of k9s to install. Accepts versions with or without the 'v' prefix."
}
}
Expand Down
25 changes: 16 additions & 9 deletions src/k9s/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,22 @@ preflight () {
main () {
preflight

if [ "${K9S_VERSION}" != "latest" ]; then
# parse the semantic version for later
local SEMVER="${K9S_VERSION#[vV]}" # strip the v
local SEMVER_MAJOR="${SEMVER%%\.*}" # split until the first .
local SEMVER_MINOR="${SEMVER#*.}" # split starting after the first .
local SEMVER_MINOR="${SEMVER_MINOR%.*}" # use previous result to grab the first element again
fi

local ARCH="$(uname -m)"
case "${ARCH}" in
"aarch64") ARCH="arm64" ;;
"x86_64")
ARCH="amd64"

if [ "${K9S_VERSION}" != "latest" ]; then
# parse the semantic version to determine what arch to use
# the file naming changed from 0.27.0 onward: https://github.com/derailed/k9s/pull/1910
local SEMVER="${K9S_VERSION#[vV]}" # strip the v
local SEMVER_MAJOR="${SEMVER%%\.*}" # split until the first .
local SEMVER_MINOR="${SEMVER#*.}" # split starting after the first .
local SEMVER_MINOR="${SEMVER_MINOR%.*}" # use previous result to grab the first element again

# the file naming for the achitectures changed from 0.27.0 onward: https://github.com/derailed/k9s/pull/1910
if [ "${SEMVER_MAJOR}" -eq "0" ] && [ "${SEMVER_MINOR}" -lt "27" ]; then
ARCH="x86_64"
fi
Expand All @@ -56,11 +58,16 @@ main () {
*) echo "The current architecture (${ARCH}) is not supported."; exit 1 ;;
esac

local K9S_CHECKSUMS_URL="https://github.com/derailed/k9s/releases/latest/download/checksums.txt"
local K9S_CHECKSUMS_URL="https://github.com/derailed/k9s/releases/latest/download/checksums.sha256"
local K9S_URL="https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_${ARCH}.tar.gz"

if [ "${K9S_VERSION}" != "latest" ] ; then
K9S_CHECKSUMS_URL="https://github.com/derailed/k9s/releases/download/v${K9S_VERSION#[vV]}/checksums.txt"
if [ "${SEMVER_MAJOR}" -eq "0" ] && [ "${SEMVER_MINOR}" -lt "28" ]; then
K9S_CHECKSUMS_URL="https://github.com/derailed/k9s/releases/download/v${K9S_VERSION#[vV]}/checksums.txt"
else
K9S_CHECKSUMS_URL="https://github.com/derailed/k9s/releases/download/v${K9S_VERSION#[vV]}/checksums.sha256"
fi

K9S_URL="https://github.com/derailed/k9s/releases/download/v${K9S_VERSION#[vV]}/k9s_Linux_${ARCH}.tar.gz"
fi

Expand Down
14 changes: 14 additions & 0 deletions test/k9s/k9s-checksum-after-v0.28.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "k9s specific version v0.28.0" /bin/bash -c "k9s version --short | grep 'v0.28.0'"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
14 changes: 14 additions & 0 deletions test/k9s/k9s-checksum-before-v0.28.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "k9s specific version v0.27.4" /bin/bash -c "k9s version --short | grep 'v0.27.4'"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
16 changes: 16 additions & 0 deletions test/k9s/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,21 @@
"version": "v0.26.0"
}
}
},
"k9s-checksum-before-v0.28.0": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"k9s": {
"version": "v0.27.4"
}
}
},
"k9s-checksum-after-v0.28.0": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"k9s": {
"version": "v0.28.0"
}
}
}
}

0 comments on commit 4a3f581

Please sign in to comment.