8000 Do not assume that helm is installed on the system by jakepearson · Pull Request #3 · jakepearson/h · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Do not assume that helm is installed on the system #3

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

Merged
merged 1 commit into from
Nov 25, 2019
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
36 changes: 26 additions & 10 deletions h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set +x

HX_PATH="$HOME/.hx"
mkdir -p "$HX_PATH/cache"
mkdir -p "$HX_PATH"

case "$OSTYPE" in
*arwin*)
Expand All @@ -15,17 +15,33 @@ case "$OSTYPE" in
OS="linux"
esac

TARGET_VERSION=$(helm version --template '{{ .Server.SemVer }}')
function GET_HELM_VERSION() {
VERSION=$1
HELM_PATH=$HX_PATH/helm-$VERSION
HELM_TAR="$HELM_PATH.tar.gz"

TARGET=$HX_PATH/helm-$TARGET_VERSION
curl -L -o "$HELM_TAR" "https://get.helm.sh/helm-$VERSION-$OS-amd64.tar.gz"
tar --extract --file="$HELM_TAR" --strip=1 --directory="$HX_PATH" $OS-amd64/helm
mv "$HX_PATH/helm" "$HELM_PATH"
rm "$HELM_TAR"
}

if [ ! -f $TARGET ]; then
cd "$HX_PATH"
curl -LO "https://get.helm.sh/helm-$TARGET_VERSION-$OS-amd64.tar.gz"
tar xvzf helm-$TARGET_VERSION-$OS-amd64.tar.gz
mv $HX_PATH/$OS-amd64/helm $TARGET
rm -rf $OS-amd64
chmod +x $TARGET
# Ensure we have at least 1 helm version
KNOWN_VERSION="v2.16.0"
LOCAL_HELM=$HX_PATH/helm-$KNOWN_VERSION
HELM_PATH=$(command -v helm)
if [ -n "$HELM_PATH" ]; then
LOCAL_HELM=$HELM_PATH
elif [ ! -f "$LOCAL_HELM" ]; then
GET_HELM_VERSION $KNOWN_VERSION
fi

TARGET_VERSION=$($LOCAL_HELM version --template '{{ .Server.SemVer }}')
echo "TARGET-$TARGET_VERSION"
TARGET="$HX_PATH/helm-$TARGET_VERSION"

if [ ! -f "$TARGET" ]; then
GET_HELM_VERSION "$TARGET_VERSION"
fi

$TARGET "$@"
0