Skip to content

Commit

Permalink
Merge pull request #3 from mboersma/linux-and-win
Browse files Browse the repository at this point in the history
Allow downloading of Linux and Windows binaries
  • Loading branch information
jakepearson authored Dec 17, 2018
2 parents 0eccda6 + b5815c6 commit 12e5ceb
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions k
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,24 @@ set +x
KX_PATH="$HOME/.kx"
mkdir -p "$KX_PATH/cache"

case "$OSTYPE" in
*arwin*)
OS="darwin"
;;
*in32* | *indows*)
OS="windows"
;;
*)
OS="linux"
esac

# Attempt to load the server version from cache
if [ ! -z "$KUBECONFIG" ]; then
KUBECONFIG_HASH=$(echo "$KUBECONFIG" | sha256sum | cut -c1-5)
if [ "$OS" == "darwin" ]; then
KUBECONFIG_HASH=$(echo "$KUBECONFIG" | shasum -a 256 | cut -c1-5)
else
KUBECONFIG_HASH=$(echo "$KUBECONFIG" | sha256sum | cut -c1-5)
fi
VERSION_CACHE_FILE="$KX_PATH/cache/$KUBECONFIG_HASH"
TARGET_VERSION=$(cat "$VERSION_CACHE_FILE" 2> /dev/null)
fi
Expand All @@ -25,9 +40,9 @@ TARGET=$KX_PATH/kubectl-$TARGET_VERSION

if [ ! -f $TARGET ]; then
cd "$KX_PATH"
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$TARGET_VERSION/bin/darwin/amd64/kubectl"
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$TARGET_VERSION/bin/$OS/amd64/kubectl"
mv $KX_PATH/kubectl $TARGET
chmod +x $TARGET
fi

$TARGET "$@"
$TARGET "$@"

0 comments on commit 12e5ceb

Please sign in to comment.