Make get-kube.sh work properly the "ci/latest" pointer

pull/6/head
Jeff Grafton 2017-04-04 16:59:19 -07:00
parent 3a3dc827e4
commit b0ae0d074e
2 changed files with 14 additions and 12 deletions

View File

@ -41,7 +41,7 @@ set -o pipefail
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd)
KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://storage.googleapis.com/kubernetes-release/release}"
KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL:-https://dl.k8s.io}"
function detect_kube_release() {
if [[ -n "${KUBE_VERSION:-}" ]]; then

View File

@ -81,7 +81,7 @@ KUBE_CI_VERSION_REGEX="^v(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)-(be
# KUBE_VERSION
function set_binary_version() {
if [[ "${1}" =~ "/" ]]; then
export KUBE_VERSION=$(curl -fL "https://dl.k8s.io/${1}.txt")
export KUBE_VERSION=$(curl -fsSL "https://dl.k8s.io/${1}.txt")
else
export KUBE_VERSION=${1}
fi
@ -93,7 +93,9 @@ function download_kube_binaries {
(
cd kubernetes
if [[ -x ./cluster/get-kube-binaries.sh ]]; then
./cluster/get-kube-binaries.sh
# Make sure to use the same download URL in get-kube-binaries.sh
KUBERNETES_RELEASE_URL="${KUBERNETES_RELEASE_URL}" \
./cluster/get-kube-binaries.sh
fi
)
}
@ -177,15 +179,15 @@ release=${KUBERNETES_RELEASE:-"release/stable"}
# Validate Kubernetes release version.
# Translate a published version <bucket>/<version> (e.g. "release/stable") to version number.
set_binary_version "${release}"
if [[ ${KUBE_VERSION} =~ ${KUBE_RELEASE_VERSION_REGEX} ]]; then
release_url="${KUBERNETES_RELEASE_URL}/${KUBE_VERSION}/${file}"
elif [[ ${KUBE_VERSION} =~ ${KUBE_CI_VERSION_REGEX} ]]; then
release_url="${KUBERNETES_CI_RELEASE_URL}/${KUBE_VERSION}/${file}"
else
if [[ ${KUBE_VERSION} =~ ${KUBE_CI_VERSION_REGEX} ]]; then
# Override KUBERNETES_RELEASE_URL to point to the CI bucket;
# this will be used by get-kube-binaries.sh.
KUBERNETES_RELEASE_URL="${KUBERNETES_CI_RELEASE_URL}"
elif ! [[ ${KUBE_VERSION} =~ ${KUBE_RELEASE_VERSION_REGEX} ]]; then
echo "Version doesn't match regexp" >&2
exit 1
fi
kubernetes_tar_url="${KUBERNETES_RELEASE_URL}/${KUBE_VERSION}/${file}"
need_download=true
if [[ -r "${PWD}/${file}" ]]; then
@ -199,7 +201,7 @@ fi
if "${need_download}"; then
echo "Downloading kubernetes release ${KUBE_VERSION}"
echo " from ${release_url}"
echo " from ${kubernetes_tar_url}"
echo " to ${PWD}/${file}"
fi
@ -225,9 +227,9 @@ fi
if "${need_download}"; then
if [[ $(which curl) ]]; then
curl -fL --retry 3 --keepalive-time 2 "${release_url}" -o "${file}"
curl -fL --retry 3 --keepalive-time 2 "${kubernetes_tar_url}" -o "${file}"
elif [[ $(which wget) ]]; then
wget "${release_url}"
wget "${kubernetes_tar_url}"
else
echo "Couldn't find curl or wget. Bailing out."
exit 1