fix get-kube-binaries.sh shellcheck lints

This commit is contained in:
Benjamin Elder 2018-09-08 13:34:25 -07:00
parent d1e5311922
commit b7ab09f572

View File

@ -39,7 +39,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd) KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://dl.k8s.io}" KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://dl.k8s.io}"
@ -50,7 +50,7 @@ function detect_kube_release() {
if [[ ! -e "${KUBE_ROOT}/version" ]]; then if [[ ! -e "${KUBE_ROOT}/version" ]]; then
echo "Can't determine Kubernetes release." >&2 echo "Can't determine Kubernetes release." >&2
echo "${BASH_SOURCE} should only be run from a prebuilt Kubernetes release." >&2 echo "${BASH_SOURCE[0]} should only be run from a prebuilt Kubernetes release." >&2
echo "Did you mean to use get-kube.sh instead?" >&2 echo "Did you mean to use get-kube.sh instead?" >&2
exit 1 exit 1
fi fi
@ -59,7 +59,8 @@ function detect_kube_release() {
} }
function detect_client_info() { function detect_client_info() {
local kernel=$(uname -s) local kernel machine
kernel="$(uname -s)"
case "${kernel}" in case "${kernel}" in
Darwin) Darwin)
CLIENT_PLATFORM="darwin" CLIENT_PLATFORM="darwin"
@ -76,7 +77,7 @@ function detect_client_info() {
# TODO: migrate the kube::util::host_platform function out of hack/lib and # TODO: migrate the kube::util::host_platform function out of hack/lib and
# use it here. # use it here.
local machine=$(uname -m) machine="$(uname -m)"
case "${machine}" in case "${machine}" in
x86_64*|i?86_64*|amd64*) x86_64*|i?86_64*|amd64*)
CLIENT_ARCH="amd64" CLIENT_ARCH="amd64"
@ -132,9 +133,10 @@ function download_tarball() {
exit 4 exit 4
fi fi
echo echo
local md5sum=$(md5sum_file "${download_path}/${file}") local md5sum sha1sum
md5sum=$(md5sum_file "${download_path}/${file}")
echo "md5sum(${file})=${md5sum}" echo "md5sum(${file})=${md5sum}"
local sha1sum=$(sha1sum_file "${download_path}/${file}") sha1sum=$(sha1sum_file "${download_path}/${file}")
echo "sha1sum(${file})=${sha1sum}" echo "sha1sum(${file})=${sha1sum}"
echo echo
# TODO: add actual verification # TODO: add actual verification
@ -151,8 +153,8 @@ function extract_arch_tarball() {
# Tarball looks like kubernetes/{client,server}/bin/BINARY" # Tarball looks like kubernetes/{client,server}/bin/BINARY"
tar -xzf "${tarfile}" --strip-components 3 -C "${platforms_dir}" tar -xzf "${tarfile}" --strip-components 3 -C "${platforms_dir}"
# Create convenience symlink # Create convenience symlink
ln -sf "${platforms_dir}" "$(dirname ${tarfile})/bin" ln -sf "${platforms_dir}" "$(dirname "${tarfile}")/bin"
echo "Add '$(dirname ${tarfile})/bin' to your PATH to use newly-installed binaries." echo "Add '$(dirname "${tarfile}")/bin' to your PATH to use newly-installed binaries."
} }
detect_kube_release detect_kube_release
@ -213,7 +215,7 @@ fi
if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then if [[ -z "${KUBERNETES_SKIP_CONFIRM-}" ]]; then
echo "Is this ok? [Y]/n" echo "Is this ok? [Y]/n"
read confirm read -r confirm
if [[ "${confirm}" =~ ^[nN]$ ]]; then if [[ "${confirm}" =~ ^[nN]$ ]]; then
echo "Aborting." echo "Aborting."
exit 1 exit 1