return value is taken from if statement instead of the function call

This commit is contained in:
Sergey Kanzhelev 2021-10-26 00:11:55 +00:00
parent 17da6a2345
commit c703725592

View File

@ -187,7 +187,7 @@ function download-or-bust {
echo "Getting the scope of service account configured for VM." echo "Getting the scope of service account configured for VM."
if ! valid-storage-scope ; then if ! valid-storage-scope ; then
canUseCredentials=$? canUseCredentials=1
# this behavior is preserved for backward compatibility. We want to fail fast if SA is not available # this behavior is preserved for backward compatibility. We want to fail fast if SA is not available
# and try to download without SA if scope does not exist on SA # and try to download without SA if scope does not exist on SA
echo "No service account or service account without storage scope. Attempt to download without service account token." echo "No service account or service account without storage scope. Attempt to download without service account token."
@ -199,9 +199,8 @@ function download-or-bust {
if access_token=$(get-credentials); then if access_token=$(get-credentials); then
echo "Service account access token is received. Downloading ${url} using this token." echo "Service account access token is received. Downloading ${url} using this token."
else else
local exit_code=$?
echo "Cannot get a service account token. Exiting." echo "Cannot get a service account token. Exiting."
exit ${exit_code} exit 1
fi fi
curl_headers=${access_token:+Authorization: Bearer "${access_token}"} curl_headers=${access_token:+Authorization: Bearer "${access_token}"}