fix: pass bearer token to curl using -H instead of --oauth2-bearer

The flag `--oauth2-bearer` might have no effect in some environment.

Signed-off-by: knight42 <anonymousknight96@gmail.com>
This commit is contained in:
knight42
2020-11-05 01:15:19 +08:00
parent e54448a307
commit 00e4234cc9
4 changed files with 6 additions and 9 deletions

View File

@@ -45,7 +45,6 @@ kube::util::wait_for_url() {
local wait=${3:-1}
local times=${4:-30}
local maxtime=${5:-1}
local extra_args=${6:-}
command -v curl >/dev/null || {
kube::log::usage "curl must be installed"
@@ -55,9 +54,7 @@ kube::util::wait_for_url() {
local i
for i in $(seq 1 "${times}"); do
local out
# shellcheck disable=SC2086
# Disabling because "${extra_args}" needs to allow for expansion here
if out=$(curl --max-time "${maxtime}" -gkfs $extra_args "${url}" 2>/dev/null); then
if out=$(curl --max-time "${maxtime}" -gkfs "${@:6}" "${url}" 2>/dev/null); then
kube::log::status "On try ${i}, ${prefix}: ${out}"
return 0
fi
@@ -75,7 +72,7 @@ kube::util::wait_for_url_with_bearer_token() {
local times=${5:-30}
local maxtime=${6:-1}
kube::util::wait_for_url "${url}" "${prefix}" "${wait}" "${times}" "${maxtime}" "--oauth2-bearer ${token}"
kube::util::wait_for_url "${url}" "${prefix}" "${wait}" "${times}" "${maxtime}" -H "Authorization: Bearer ${token}"
}
# Example: kube::util::wait_for_success 120 5 "kubectl get nodes|grep localhost"