fix: lint bash scripts with shellcheck

Fix shellcheck warnings across all bash scripts in scripts/:
- Quote default assignments to prevent globbing (SC2223)
- Replace backticks with $() syntax (SC2006)
- Use [ a ] && [ b ] instead of [ a -a b ] (SC2166)
- Remove legacy x-prefix comparisons (SC2268)
- Separate local declaration from assignment (SC2155)
- Quote variables to prevent word splitting (SC2086)
- Use mapfile instead of array=($(cmd)) (SC2207)
- Replace expr with $((...)) arithmetic (SC2003)
- Refactor command existence checks (SC2181/SC2034)

Closes #31689

Signed-off-by: Moritz Röseler <moritz.roeseler@gmail.com>
pull/31763/head
Moritz Röseler 9 months ago
parent f928025cdb
commit 241770ec1a

@ -20,13 +20,13 @@
PROJECT_NAME="helm" PROJECT_NAME="helm"
TILLER_NAME="tiller" TILLER_NAME="tiller"
: ${USE_SUDO:="true"} : "${USE_SUDO:=true}"
: ${HELM_INSTALL_DIR:="/usr/local/bin"} : "${HELM_INSTALL_DIR:=/usr/local/bin}"
# initArch discovers the architecture for this system. # initArch discovers the architecture for this system.
initArch() { initArch() {
ARCH=$(uname -m) ARCH=$(uname -m)
case $ARCH in case "$ARCH" in
armv5*) ARCH="armv5";; armv5*) ARCH="armv5";;
armv6*) ARCH="armv6";; armv6*) ARCH="armv6";;
armv7*) ARCH="arm";; armv7*) ARCH="arm";;
@ -40,7 +40,7 @@ initArch() {
# initOS discovers the operating system for this system. # initOS discovers the operating system for this system.
initOS() { initOS() {
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') OS=$(uname | tr '[:upper:]' '[:lower:]')
case "$OS" in case "$OS" in
# Minimalist GNU for Windows # Minimalist GNU for Windows
@ -50,7 +50,7 @@ initOS() {
# runs the given command as root (detects if we are root already) # runs the given command as root (detects if we are root already)
runAsRoot() { runAsRoot() {
if [ $EUID -ne 0 -a "$USE_SUDO" = "true" ]; then if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then
sudo "${@}" sudo "${@}"
else else
"${@}" "${@}"
@ -75,7 +75,7 @@ verifySupported() {
# checkDesiredVersion checks if the desired version is available. # checkDesiredVersion checks if the desired version is available.
checkDesiredVersion() { checkDesiredVersion() {
if [ "x$DESIRED_VERSION" == "x" ]; then if [ -z "$DESIRED_VERSION" ]; then
# Pinning tag to v2.17.0 as per https://github.com/helm/helm/issues/9607 # Pinning tag to v2.17.0 as per https://github.com/helm/helm/issues/9607
TAG=v2.17.0 TAG=v2.17.0
else else
@ -87,7 +87,8 @@ checkDesiredVersion() {
# 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}/${PROJECT_NAME}" ]]; then
local version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version -c | grep '^Client' | cut -d'"' -f2) local version
version=$("${HELM_INSTALL_DIR}/${PROJECT_NAME}" version -c | grep '^Client' | cut -d'"' -f2)
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
@ -126,8 +127,10 @@ downloadFile() {
# installs it. # installs it.
installFile() { installFile() {
HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME" HELM_TMP="$HELM_TMP_ROOT/$PROJECT_NAME"
local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') local sum
local expected_sum=$(cat ${HELM_SUM_FILE}) sum=$(openssl sha1 -sha256 "${HELM_TMP_FILE}" | awk '{print $2}')
local expected_sum
expected_sum=$(cat "${HELM_SUM_FILE}")
if [ "$sum" != "$expected_sum" ]; then if [ "$sum" != "$expected_sum" ]; then
echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting."
exit 1 exit 1
@ -166,13 +169,11 @@ 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 if ! command -v "$PROJECT_NAME" &> /dev/null; then
HELM="$(command -v $PROJECT_NAME)" # shellcheck disable=SC2016
if [ "$?" = "1" ]; then echo "$PROJECT_NAME not found. Is $HELM_INSTALL_DIR on your "'\$PATH?'
echo "$PROJECT_NAME not found. Is $HELM_INSTALL_DIR on your "'$PATH?'
exit 1 exit 1
fi fi
set -e
echo "Run '$PROJECT_NAME init' to configure $PROJECT_NAME." echo "Run '$PROJECT_NAME init' to configure $PROJECT_NAME."
} }
@ -195,11 +196,11 @@ cleanup() {
# Execution # Execution
#Stop execution on any error #Stop execution on any error
trap "fail_trap" EXIT trap 'fail_trap' EXIT
set -e set -e
# Parsing input arguments (if any) # Parsing input arguments (if any)
export INPUT_ARGUMENTS="${@}" export INPUT_ARGUMENTS="$*"
set -u set -u
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in

@ -17,13 +17,13 @@
# 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
: ${BINARY_NAME:="helm"} : "${BINARY_NAME:=helm}"
: ${USE_SUDO:="true"} : "${USE_SUDO:=true}"
: ${DEBUG:="false"} : "${DEBUG:=false}"
: ${VERIFY_CHECKSUM:="true"} : "${VERIFY_CHECKSUM:=true}"
: ${VERIFY_SIGNATURES:="false"} : "${VERIFY_SIGNATURES:=false}"
: ${HELM_INSTALL_DIR:="/usr/local/bin"} : "${HELM_INSTALL_DIR:=/usr/local/bin}"
: ${GPG_PUBRING:="pubring.kbx"} : "${GPG_PUBRING:=pubring.kbx}"
HAS_CURL="$(type "curl" &> /dev/null && echo true || echo false)" HAS_CURL="$(type "curl" &> /dev/null && echo true || echo false)"
HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)" HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)"
@ -35,7 +35,7 @@ HAS_TAR="$(type "tar" &> /dev/null && echo true || echo false)"
# initArch discovers the architecture for this system. # initArch discovers the architecture for this system.
initArch() { initArch() {
ARCH=$(uname -m) ARCH=$(uname -m)
case $ARCH in case "$ARCH" in
armv5*) ARCH="armv5";; armv5*) ARCH="armv5";;
armv6*) ARCH="armv6";; armv6*) ARCH="armv6";;
armv7*) ARCH="arm";; armv7*) ARCH="arm";;
@ -49,7 +49,7 @@ initArch() {
# initOS discovers the operating system for this system. # initOS discovers the operating system for this system.
initOS() { initOS() {
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') OS=$(uname | tr '[:upper:]' '[:lower:]')
case "$OS" in case "$OS" in
# Minimalist GNU for Windows # Minimalist GNU for Windows
@ -59,7 +59,7 @@ initOS() {
# runs the given command as root (detects if we are root already) # runs the given command as root (detects if we are root already)
runAsRoot() { runAsRoot() {
if [ $EUID -ne 0 -a "$USE_SUDO" = "true" ]; then if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then
sudo "${@}" sudo "${@}"
else else
"${@}" "${@}"
@ -112,7 +112,7 @@ verifySupported() {
# checkDesiredVersion checks if the desired version is available. # checkDesiredVersion checks if the desired version is available.
checkDesiredVersion() { checkDesiredVersion() {
if [ "x$DESIRED_VERSION" == "x" ]; then if [ -z "$DESIRED_VERSION" ]; then
# Get tag from release URL # Get tag from release URL
local latest_release_url="https://get.helm.sh/helm3-latest-version" local latest_release_url="https://get.helm.sh/helm3-latest-version"
local latest_release_response="" local latest_release_response=""
@ -122,7 +122,7 @@ checkDesiredVersion() {
latest_release_response=$( wget "$latest_release_url" -q -O - 2>&1 || true ) latest_release_response=$( wget "$latest_release_url" -q -O - 2>&1 || true )
fi fi
TAG=$( echo "$latest_release_response" | grep '^v[0-9]' ) TAG=$( echo "$latest_release_response" | grep '^v[0-9]' )
if [ "x$TAG" == "x" ]; then if [ -z "$TAG" ]; then
printf "Could not retrieve the latest release tag information from %s: %s\n" "${latest_release_url}" "${latest_release_response}" printf "Could not retrieve the latest release tag information from %s: %s\n" "${latest_release_url}" "${latest_release_response}"
exit 1 exit 1
fi fi
@ -135,7 +135,8 @@ checkDesiredVersion() {
# if it needs to be changed. # if it needs to be changed.
checkHelmInstalledVersion() { checkHelmInstalledVersion() {
if [[ -f "${HELM_INSTALL_DIR}/${BINARY_NAME}" ]]; then if [[ -f "${HELM_INSTALL_DIR}/${BINARY_NAME}" ]]; then
local version=$("${HELM_INSTALL_DIR}/${BINARY_NAME}" version --template="{{ .Version }}") local version
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
@ -193,8 +194,10 @@ installFile() {
# verifyChecksum verifies the SHA256 checksum of the binary package. # verifyChecksum verifies the SHA256 checksum of the binary package.
verifyChecksum() { verifyChecksum() {
printf "Verifying checksum... " printf "Verifying checksum... "
local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') local sum
local expected_sum=$(cat ${HELM_SUM_FILE}) sum=$(openssl sha1 -sha256 "${HELM_TMP_FILE}" | awk '{print $2}')
local expected_sum
expected_sum=$(cat "${HELM_SUM_FILE}")
if [ "$sum" != "$expected_sum" ]; then if [ "$sum" != "$expected_sum" ]; then
echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting."
exit 1 exit 1
@ -216,7 +219,8 @@ verifySignatures() {
fi fi
local gpg_keyring="${HELM_TMP_ROOT}/keyring.gpg" local gpg_keyring="${HELM_TMP_ROOT}/keyring.gpg"
local gpg_homedir="${HELM_TMP_ROOT}/gnupg" local gpg_homedir="${HELM_TMP_ROOT}/gnupg"
mkdir -p -m 0700 "${gpg_homedir}" mkdir -p "${gpg_homedir}"
chmod 0700 "${gpg_homedir}"
local gpg_stderr_device="/dev/null" local gpg_stderr_device="/dev/null"
if [ "${DEBUG}" == "true" ]; then if [ "${DEBUG}" == "true" ]; then
gpg_stderr_device="/dev/stderr" gpg_stderr_device="/dev/stderr"
@ -233,13 +237,15 @@ verifySignatures() {
fi fi
local error_text="If you think this might be a potential security issue," local error_text="If you think this might be a potential security issue,"
error_text="${error_text}\nplease see here: https://github.com/helm/community/blob/master/SECURITY.md" error_text="${error_text}\nplease see here: https://github.com/helm/community/blob/master/SECURITY.md"
local num_goodlines_sha=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)') local num_goodlines_sha
num_goodlines_sha=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)')
if [[ ${num_goodlines_sha} -lt 2 ]]; then if [[ ${num_goodlines_sha} -lt 2 ]]; then
echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256!" echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256!"
echo -e "${error_text}" echo -e "${error_text}"
exit 1 exit 1
fi fi
local num_goodlines_tar=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)') local num_goodlines_tar
num_goodlines_tar=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)')
if [[ ${num_goodlines_tar} -lt 2 ]]; then if [[ ${num_goodlines_tar} -lt 2 ]]; then
echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz!" echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz!"
echo -e "${error_text}" echo -e "${error_text}"
@ -266,13 +272,11 @@ 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 if ! command -v "$BINARY_NAME" &> /dev/null; then
HELM="$(command -v $BINARY_NAME)" # shellcheck disable=SC2016
if [ "$?" = "1" ]; then echo "$BINARY_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
} }
# help provides possible cli installation arguments # help provides possible cli installation arguments
@ -294,7 +298,7 @@ cleanup() {
# Execution # Execution
#Stop execution on any error #Stop execution on any error
trap "fail_trap" EXIT trap 'fail_trap' EXIT
set -e set -e
# Set debug if desired # Set debug if desired
@ -303,7 +307,7 @@ if [ "${DEBUG}" == "true" ]; then
fi fi
# Parsing input arguments (if any) # Parsing input arguments (if any)
export INPUT_ARGUMENTS="${@}" export INPUT_ARGUMENTS="$*"
set -u set -u
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in

@ -17,13 +17,13 @@
# 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
: ${BINARY_NAME:="helm"} : "${BINARY_NAME:=helm}"
: ${USE_SUDO:="true"} : "${USE_SUDO:=true}"
: ${DEBUG:="false"} : "${DEBUG:=false}"
: ${VERIFY_CHECKSUM:="true"} : "${VERIFY_CHECKSUM:=true}"
: ${VERIFY_SIGNATURES:="false"} : "${VERIFY_SIGNATURES:=false}"
: ${HELM_INSTALL_DIR:="/usr/local/bin"} : "${HELM_INSTALL_DIR:=/usr/local/bin}"
: ${GPG_PUBRING:="pubring.kbx"} : "${GPG_PUBRING:=pubring.kbx}"
HAS_CURL="$(type "curl" &> /dev/null && echo true || echo false)" HAS_CURL="$(type "curl" &> /dev/null && echo true || echo false)"
HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)" HAS_WGET="$(type "wget" &> /dev/null && echo true || echo false)"
@ -35,7 +35,7 @@ HAS_TAR="$(type "tar" &> /dev/null && echo true || echo false)"
# initArch discovers the architecture for this system. # initArch discovers the architecture for this system.
initArch() { initArch() {
ARCH=$(uname -m) ARCH=$(uname -m)
case $ARCH in case "$ARCH" in
armv5*) ARCH="armv5";; armv5*) ARCH="armv5";;
armv6*) ARCH="armv6";; armv6*) ARCH="armv6";;
armv7*) ARCH="arm";; armv7*) ARCH="arm";;
@ -49,7 +49,7 @@ initArch() {
# initOS discovers the operating system for this system. # initOS discovers the operating system for this system.
initOS() { initOS() {
OS=$(echo `uname`|tr '[:upper:]' '[:lower:]') OS=$(uname | tr '[:upper:]' '[:lower:]')
case "$OS" in case "$OS" in
# Minimalist GNU for Windows # Minimalist GNU for Windows
@ -59,7 +59,7 @@ initOS() {
# runs the given command as root (detects if we are root already) # runs the given command as root (detects if we are root already)
runAsRoot() { runAsRoot() {
if [ $EUID -ne 0 -a "$USE_SUDO" = "true" ]; then if [ $EUID -ne 0 ] && [ "$USE_SUDO" = "true" ]; then
sudo "${@}" sudo "${@}"
else else
"${@}" "${@}"
@ -112,7 +112,7 @@ verifySupported() {
# checkDesiredVersion checks if the desired version is available. # checkDesiredVersion checks if the desired version is available.
checkDesiredVersion() { checkDesiredVersion() {
if [ "x$DESIRED_VERSION" == "x" ]; then if [ -z "$DESIRED_VERSION" ]; then
# Get tag from release URL # Get tag from release URL
local latest_release_url="https://get.helm.sh/helm4-latest-version" local latest_release_url="https://get.helm.sh/helm4-latest-version"
local latest_release_response="" local latest_release_response=""
@ -122,7 +122,7 @@ checkDesiredVersion() {
latest_release_response=$( wget "$latest_release_url" -q -O - 2>&1 || true ) latest_release_response=$( wget "$latest_release_url" -q -O - 2>&1 || true )
fi fi
TAG=$( echo "$latest_release_response" | grep '^v[0-9]' ) TAG=$( echo "$latest_release_response" | grep '^v[0-9]' )
if [ "x$TAG" == "x" ]; then if [ -z "$TAG" ]; then
printf "Could not retrieve the latest release tag information from %s: %s\n" "${latest_release_url}" "${latest_release_response}" printf "Could not retrieve the latest release tag information from %s: %s\n" "${latest_release_url}" "${latest_release_response}"
exit 1 exit 1
fi fi
@ -135,7 +135,8 @@ checkDesiredVersion() {
# if it needs to be changed. # if it needs to be changed.
checkHelmInstalledVersion() { checkHelmInstalledVersion() {
if [[ -f "${HELM_INSTALL_DIR}/${BINARY_NAME}" ]]; then if [[ -f "${HELM_INSTALL_DIR}/${BINARY_NAME}" ]]; then
local version=$("${HELM_INSTALL_DIR}/${BINARY_NAME}" version --template="{{ .Version }}") local version
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
@ -193,8 +194,10 @@ installFile() {
# verifyChecksum verifies the SHA256 checksum of the binary package. # verifyChecksum verifies the SHA256 checksum of the binary package.
verifyChecksum() { verifyChecksum() {
printf "Verifying checksum... " printf "Verifying checksum... "
local sum=$(openssl sha1 -sha256 ${HELM_TMP_FILE} | awk '{print $2}') local sum
local expected_sum=$(cat ${HELM_SUM_FILE}) sum=$(openssl sha1 -sha256 "${HELM_TMP_FILE}" | awk '{print $2}')
local expected_sum
expected_sum=$(cat "${HELM_SUM_FILE}")
if [ "$sum" != "$expected_sum" ]; then if [ "$sum" != "$expected_sum" ]; then
echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting." echo "SHA sum of ${HELM_TMP_FILE} does not match. Aborting."
exit 1 exit 1
@ -216,7 +219,8 @@ verifySignatures() {
fi fi
local gpg_keyring="${HELM_TMP_ROOT}/keyring.gpg" local gpg_keyring="${HELM_TMP_ROOT}/keyring.gpg"
local gpg_homedir="${HELM_TMP_ROOT}/gnupg" local gpg_homedir="${HELM_TMP_ROOT}/gnupg"
mkdir -p -m 0700 "${gpg_homedir}" mkdir -p "${gpg_homedir}"
chmod 0700 "${gpg_homedir}"
local gpg_stderr_device="/dev/null" local gpg_stderr_device="/dev/null"
if [ "${DEBUG}" == "true" ]; then if [ "${DEBUG}" == "true" ]; then
gpg_stderr_device="/dev/stderr" gpg_stderr_device="/dev/stderr"
@ -233,13 +237,15 @@ verifySignatures() {
fi fi
local error_text="If you think this might be a potential security issue," local error_text="If you think this might be a potential security issue,"
error_text="${error_text}\nplease see here: https://github.com/helm/community/blob/master/SECURITY.md" error_text="${error_text}\nplease see here: https://github.com/helm/community/blob/master/SECURITY.md"
local num_goodlines_sha=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)') local num_goodlines_sha
num_goodlines_sha=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)')
if [[ ${num_goodlines_sha} -lt 2 ]]; then if [[ ${num_goodlines_sha} -lt 2 ]]; then
echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256!" echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz.sha256!"
echo -e "${error_text}" echo -e "${error_text}"
exit 1 exit 1
fi fi
local num_goodlines_tar=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)') local num_goodlines_tar
num_goodlines_tar=$(gpg --verify --keyring="${gpg_keyring}" --status-fd=1 "${HELM_TMP_ROOT}/helm-${TAG}-${OS}-${ARCH}.tar.gz.asc" 2> "${gpg_stderr_device}" | grep -c -E '^\[GNUPG:\] (GOODSIG|VALIDSIG)')
if [[ ${num_goodlines_tar} -lt 2 ]]; then if [[ ${num_goodlines_tar} -lt 2 ]]; then
echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz!" echo "Unable to verify the signature of helm-${TAG}-${OS}-${ARCH}.tar.gz!"
echo -e "${error_text}" echo -e "${error_text}"
@ -266,13 +272,11 @@ 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 if ! command -v "$BINARY_NAME" &> /dev/null; then
HELM="$(command -v $BINARY_NAME)" # shellcheck disable=SC2016
if [ "$?" = "1" ]; then echo "$BINARY_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
} }
# help provides possible cli installation arguments # help provides possible cli installation arguments
@ -294,7 +298,7 @@ cleanup() {
# Execution # Execution
#Stop execution on any error #Stop execution on any error
trap "fail_trap" EXIT trap 'fail_trap' EXIT
set -e set -e
# Set debug if desired # Set debug if desired
@ -303,7 +307,7 @@ if [ "${DEBUG}" == "true" ]; then
fi fi
# Parsing input arguments (if any) # Parsing input arguments (if any)
export INPUT_ARGUMENTS="${@}" export INPUT_ARGUMENTS="$*"
set -u set -u
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case $1 in case $1 in

@ -29,10 +29,10 @@ if [[ -z "${PREVIOUS_RELEASE}" || -z "${RELEASE}" ]]; then
fi fi
## validate git tags ## validate git tags
for tag in $RELEASE $PREVIOUS_RELEASE; do for tag in "$RELEASE" "$PREVIOUS_RELEASE"; do
OK=$(git tag -l ${tag} | wc -l) OK=$(git tag -l "${tag}" | wc -l)
if [[ "$OK" == "0" ]]; then if [[ "$OK" == "0" ]]; then
echo ${tag} is not a valid release version echo "${tag} is not a valid release version"
exit 1 exit 1
fi fi
done done
@ -46,17 +46,16 @@ if [[ ! -e "./_dist/helm-${RELEASE}-darwin-amd64.tar.gz.sha256sum" ]]; then
fi fi
## Generate CHANGELOG from git log ## Generate CHANGELOG from git log
CHANGELOG=$(git log --no-merges --pretty=format:'- %s %H (%aN)' ${PREVIOUS_RELEASE}..${RELEASE}) if ! CHANGELOG=$(git log --no-merges --pretty=format:'- %s %H (%aN)' "${PREVIOUS_RELEASE}".."${RELEASE}"); then
if [[ ! $? -eq 0 ]]; then
echo "Error creating changelog" echo "Error creating changelog"
echo "try running \`git log --no-merges --pretty=format:'- %s %H (%aN)' ${PREVIOUS_RELEASE}..${RELEASE}\`" echo "try running \`git log --no-merges --pretty=format:'- %s %H (%aN)' ${PREVIOUS_RELEASE}..${RELEASE}\`"
exit 1 exit 1
fi fi
## guess at MAJOR / MINOR / PATCH versions ## guess at MAJOR / MINOR / PATCH versions
MAJOR=$(echo ${RELEASE} | sed 's/^v//' | cut -f1 -d.) MAJOR=$(echo "${RELEASE}" | sed 's/^v//' | cut -f1 -d.)
MINOR=$(echo ${RELEASE} | sed 's/^v//' | cut -f2 -d.) MINOR=$(echo "${RELEASE}" | sed 's/^v//' | cut -f2 -d.)
PATCH=$(echo ${RELEASE} | sed 's/^v//' | cut -f3 -d.) PATCH=$(echo "${RELEASE}" | sed 's/^v//' | cut -f3 -d.)
## Print release notes to stdout ## Print release notes to stdout
cat <<EOF cat <<EOF
@ -81,25 +80,25 @@ The community keeps growing, and we'd love to see you there!
Download Helm ${RELEASE}. The common platform binaries are here: Download Helm ${RELEASE}. The common platform binaries are here:
- [MacOS amd64](https://get.helm.sh/helm-${RELEASE}-darwin-amd64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-darwin-amd64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-darwin-amd64.tar.gz.sha256)) - [MacOS amd64](https://get.helm.sh/helm-${RELEASE}-darwin-amd64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-darwin-amd64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-darwin-amd64.tar.gz.sha256"))
- [MacOS arm64](https://get.helm.sh/helm-${RELEASE}-darwin-arm64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-darwin-arm64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-darwin-arm64.tar.gz.sha256)) - [MacOS arm64](https://get.helm.sh/helm-${RELEASE}-darwin-arm64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-darwin-arm64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-darwin-arm64.tar.gz.sha256"))
- [Linux amd64](https://get.helm.sh/helm-${RELEASE}-linux-amd64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-amd64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-amd64.tar.gz.sha256)) - [Linux amd64](https://get.helm.sh/helm-${RELEASE}-linux-amd64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-amd64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-amd64.tar.gz.sha256"))
- [Linux arm](https://get.helm.sh/helm-${RELEASE}-linux-arm.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-arm.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-arm.tar.gz.sha256)) - [Linux arm](https://get.helm.sh/helm-${RELEASE}-linux-arm.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-arm.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-arm.tar.gz.sha256"))
- [Linux arm64](https://get.helm.sh/helm-${RELEASE}-linux-arm64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-arm64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-arm64.tar.gz.sha256)) - [Linux arm64](https://get.helm.sh/helm-${RELEASE}-linux-arm64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-arm64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-arm64.tar.gz.sha256"))
- [Linux i386](https://get.helm.sh/helm-${RELEASE}-linux-386.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-386.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-386.tar.gz.sha256)) - [Linux i386](https://get.helm.sh/helm-${RELEASE}-linux-386.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-386.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-386.tar.gz.sha256"))
- [Linux loong64](https://get.helm.sh/helm-${RELEASE}-linux-loong64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-loong64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-loong64.tar.gz.sha256)) - [Linux loong64](https://get.helm.sh/helm-${RELEASE}-linux-loong64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-loong64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-loong64.tar.gz.sha256"))
- [Linux ppc64le](https://get.helm.sh/helm-${RELEASE}-linux-ppc64le.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-ppc64le.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-ppc64le.tar.gz.sha256)) - [Linux ppc64le](https://get.helm.sh/helm-${RELEASE}-linux-ppc64le.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-ppc64le.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-ppc64le.tar.gz.sha256"))
- [Linux s390x](https://get.helm.sh/helm-${RELEASE}-linux-s390x.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-s390x.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-s390x.tar.gz.sha256)) - [Linux s390x](https://get.helm.sh/helm-${RELEASE}-linux-s390x.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-s390x.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-s390x.tar.gz.sha256"))
- [Linux riscv64](https://get.helm.sh/helm-${RELEASE}-linux-riscv64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-riscv64.tar.gz.sha256sum) / $(cat _dist/helm-${RELEASE}-linux-riscv64.tar.gz.sha256)) - [Linux riscv64](https://get.helm.sh/helm-${RELEASE}-linux-riscv64.tar.gz) ([checksum](https://get.helm.sh/helm-${RELEASE}-linux-riscv64.tar.gz.sha256sum) / $(cat "_dist/helm-${RELEASE}-linux-riscv64.tar.gz.sha256"))
- [Windows amd64](https://get.helm.sh/helm-${RELEASE}-windows-amd64.zip) ([checksum](https://get.helm.sh/helm-${RELEASE}-windows-amd64.zip.sha256sum) / $(cat _dist/helm-${RELEASE}-windows-amd64.zip.sha256)) - [Windows amd64](https://get.helm.sh/helm-${RELEASE}-windows-amd64.zip) ([checksum](https://get.helm.sh/helm-${RELEASE}-windows-amd64.zip.sha256sum) / $(cat "_dist/helm-${RELEASE}-windows-amd64.zip.sha256"))
- [Windows arm64](https://get.helm.sh/helm-${RELEASE}-windows-arm64.zip) ([checksum](https://get.helm.sh/helm-${RELEASE}-windows-arm64.zip.sha256sum) / $(cat _dist/helm-${RELEASE}-windows-arm64.zip.sha256)) - [Windows arm64](https://get.helm.sh/helm-${RELEASE}-windows-arm64.zip) ([checksum](https://get.helm.sh/helm-${RELEASE}-windows-arm64.zip.sha256sum) / $(cat "_dist/helm-${RELEASE}-windows-arm64.zip.sha256"))
The [Quickstart Guide](https://helm.sh/docs/intro/quickstart/) will get you going from there. For **upgrade instructions** or detailed installation notes, check the [install guide](https://helm.sh/docs/intro/install/). You can also use a [script to install](https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3) on any system with \`bash\`. The [Quickstart Guide](https://helm.sh/docs/intro/quickstart/) will get you going from there. For **upgrade instructions** or detailed installation notes, check the [install guide](https://helm.sh/docs/intro/install/). You can also use a [script to install](https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3) on any system with \`bash\`.
## What's Next ## What's Next
- ${MAJOR}.${MINOR}.$(expr ${PATCH} + 1) will contain only bug fixes. - ${MAJOR}.${MINOR}.$((PATCH + 1)) will contain only bug fixes.
- ${MAJOR}.$(expr ${MINOR} + 1).${PATCH} is the next feature release. This release will focus on ... - ${MAJOR}.$((MINOR + 1)).${PATCH} is the next feature release. This release will focus on ...
## Changelog ## Changelog

@ -28,7 +28,7 @@ kube::util::trap_add() {
local new_cmd local new_cmd
# Grab the currently defined trap commands for this trap # Grab the currently defined trap commands for this trap
existing_cmd=`trap -p "${trap_add_name}" | awk -F"'" '{print $2}'` existing_cmd=$(trap -p "${trap_add_name}" | awk -F"'" '{print $2}')
if [[ -z "${existing_cmd}" ]]; then if [[ -z "${existing_cmd}" ]]; then
new_cmd="${trap_add_cmd}" new_cmd="${trap_add_cmd}"
@ -36,7 +36,8 @@ kube::util::trap_add() {
new_cmd="${existing_cmd};${trap_add_cmd}" new_cmd="${existing_cmd};${trap_add_cmd}"
fi fi
# Assign the test # Assign the test - expand now is intentional as we're building the command dynamically
# shellcheck disable=SC2064
trap "${new_cmd}" "${trap_add_name}" trap "${new_cmd}" "${trap_add_name}"
done done
} }

@ -28,7 +28,7 @@ find_files() {
} }
# Use "|| :" to ignore the error code when grep returns empty # Use "|| :" to ignore the error code when grep returns empty
failed_license_header=($(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")' || :)) mapfile -t failed_license_header < <(find_files | xargs grep -L 'Licensed under the Apache License, Version 2.0 (the "License")' || :)
if (( ${#failed_license_header[@]} > 0 )); then if (( ${#failed_license_header[@]} > 0 )); then
echo "Some source files are missing license headers." echo "Some source files are missing license headers."
printf '%s\n' "${failed_license_header[@]}" printf '%s\n' "${failed_license_header[@]}"
@ -36,7 +36,7 @@ if (( ${#failed_license_header[@]} > 0 )); then
fi fi
# Use "|| :" to ignore the error code when grep returns empty # Use "|| :" to ignore the error code when grep returns empty
failed_copyright_header=($(find_files | xargs grep -L 'Copyright The Helm Authors.' || :)) mapfile -t failed_copyright_header < <(find_files | xargs grep -L 'Copyright The Helm Authors.' || :)
if (( ${#failed_copyright_header[@]} > 0 )); then if (( ${#failed_copyright_header[@]} > 0 )); then
echo "Some source files are missing the copyright header." echo "Some source files are missing the copyright header."
printf '%s\n' "${failed_copyright_header[@]}" printf '%s\n' "${failed_copyright_header[@]}"

Loading…
Cancel
Save