Make get script eaiser for helm versions to live side by side (helm3 etc) (#7752)

* Make get script eaiser for helm versions to live side by side (helm3 etc)

Signed-off-by: Scott Rigby <scott@r6by.com>

* Change PROJECT_NAME to BINARY_NAME for purpose clarity

Signed-off-by: Scott Rigby <scott@r6by.com>
pull/7758/head
Scott Rigby 5 years ago committed by GitHub
parent 0767539279
commit 4276acdf4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,8 +17,7 @@
# The install script is based off of the MIT-licensed script from glide, # The install script is based off of the MIT-licensed script from glide,
# the package manager for Go: https://github.com/Masterminds/glide.sh/blob/master/get # the package manager for Go: https://github.com/Masterminds/glide.sh/blob/master/get
PROJECT_NAME="helm" : ${BINARY_NAME:="helm"}
: ${USE_SUDO:="true"} : ${USE_SUDO:="true"}
: ${HELM_INSTALL_DIR:="/usr/local/bin"} : ${HELM_INSTALL_DIR:="/usr/local/bin"}
@ -92,8 +91,8 @@ checkDesiredVersion() {
# checkHelmInstalledVersion checks which version of helm is installed and # checkHelmInstalledVersion checks which version of helm is installed and
# if it needs to be changed. # if it needs to be changed.
checkHelmInstalledVersion() { checkHelmInstalledVersion() {
if [[ -f "${HELM_INSTALL_DIR}/${PROJECT_NAME}" ]]; then if [[ -f "${HELM_INSTALL_DIR}/${BINARY_NAME}" ]]; then
local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version --template="{{ .Version }}") local version=$("${HELM_INSTALL_DIR}/${BINARY_NAME}" version --template="{{ .Version }}")
if [[ "$version" == "$TAG" ]]; then if [[ "$version" == "$TAG" ]]; then
echo "Helm ${version} is already ${DESIRED_VERSION:-latest}" echo "Helm ${version} is already ${DESIRED_VERSION:-latest}"
return 0 return 0
@ -131,7 +130,7 @@ downloadFile() {
# installFile verifies the SHA256 for the file, then unpacks and # installFile verifies the SHA256 for the file, then unpacks and
# installs it. # installs it.
installFile() { installFile() {
HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" HELM_TMP="$HELM_TMP_ROOT/$BINARY_NAME"
local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}')
local expected_sum=$(cat ${HELM_SUM_FILE}) local expected_sum=$(cat ${HELM_SUM_FILE})
if [ "$sum" != "$expected_sum" ]; then if [ "$sum" != "$expected_sum" ]; then
@ -141,10 +140,10 @@ installFile() {
mkdir -p "$HELM_TMP" mkdir -p "$HELM_TMP"
tar xf "$HELM_TMP_FILE" -C "$HELM_TMP" tar xf "$HELM_TMP_FILE" -C "$HELM_TMP"
HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/$PROJECT_NAME" HELM_TMP_BIN="$HELM_TMP/$OS-$ARCH/helm"
echo "Preparing to install $PROJECT_NAME into ${HELM_INSTALL_DIR}" echo "Preparing to install $BINARY_NAME into ${HELM_INSTALL_DIR}"
runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR" runAsRoot cp "$HELM_TMP_BIN" "$HELM_INSTALL_DIR/$BINARY_NAME"
echo "$PROJECT_NAME installed into $HELM_INSTALL_DIR/$PROJECT_NAME" echo "$BINARY_NAME installed into $HELM_INSTALL_DIR/$BINARY_NAME"
} }
# fail_trap is executed if an error occurs. # fail_trap is executed if an error occurs.
@ -152,10 +151,10 @@ fail_trap() {
result=$? result=$?
if [ "$result" != "0" ]; then if [ "$result" != "0" ]; then
if [[ -n "$INPUT_ARGUMENTS" ]]; then if [[ -n "$INPUT_ARGUMENTS" ]]; then
echo "Failed to install $PROJECT_NAME with the arguments provided: $INPUT_ARGUMENTS" echo "Failed to install $BINARY_NAME with the arguments provided: $INPUT_ARGUMENTS"
help help
else else
echo "Failed to install $PROJECT_NAME" echo "Failed to install $BINARY_NAME"
fi fi
echo -e "\tFor support, go to https://github.com/helm/helm." echo -e "\tFor support, go to https://github.com/helm/helm."
fi fi
@ -166,9 +165,9 @@ fail_trap() {
# testVersion tests the installed client to make sure it is working. # testVersion tests the installed client to make sure it is working.
testVersion() { testVersion() {
set +e set +e
HELM="$(which $PROJECT_NAME)" HELM="$(which $BINARY_NAME)"
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
echo "$PROJECT_NAME not found. Is $HELM_INSTALL_DIR on your "'$PATH?' echo "$BINARY_NAME not found. Is $HELM_INSTALL_DIR on your "'$PATH?'
exit 1 exit 1
fi fi
set -e set -e

Loading…
Cancel
Save