Skip to content
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

Cherry pick of #7448 onto release-1.14 #7455

Merged
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
19 changes: 7 additions & 12 deletions pkg/model/resources/nodeup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -132,18 +128,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
19 changes: 7 additions & 12 deletions pkg/model/tests/data/bootstrapscript_5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ function ensure-install-dir() {
cd ${INSTALL_DIR}
}

# Retry a download until we get it. Takes a hash and a set of URLs.
#
# $1 is the sha1 of the URL. Can be "" if the sha1 is unknown.
# $2+ are the URLs to download.
# Retry a download until we get it. args: name, sha, url1, url2...
download-or-bust() {
local -r hash="$1"
shift 1
local -r file="$1"
local -r hash="$2"
shift 2

urls=( $* )
while true; do
for url in "${urls[@]}"; do
local file="${url##*/}"

if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="

Expand Down Expand Up @@ -121,18 +117,17 @@ function try-download-release() {
# optimization.

local -r nodeup_urls=( $(split-commas "${NODEUP_URL}") )
local -r nodeup_filename="${nodeup_urls[0]##*/}"
if [[ -n "${NODEUP_HASH:-}" ]]; then
local -r nodeup_hash="${NODEUP_HASH}"
else
# TODO: Remove?
echo "Downloading sha1 (not found in env)"
download-or-bust "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat "${nodeup_filename}.sha1")
download-or-bust nodeup.sha1 "" "${nodeup_urls[@]/%/.sha1}"
local -r nodeup_hash=$(cat nodeup.sha1)
fi

echo "Downloading nodeup (${nodeup_urls[@]})"
download-or-bust "${nodeup_hash}" "${nodeup_urls[@]}"
download-or-bust nodeup "${nodeup_hash}" "${nodeup_urls[@]}"

chmod +x nodeup
}
Expand Down
Loading