Merge pull request #96204 from knight42/fix/curl-bearer-token

fix: pass bearer token to curl using --header instead of --oauth2-bearer
This commit is contained in:
Kubernetes Prow Robot
2020-11-04 10:38:53 -08:00
committed by GitHub
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"

View File

@@ -97,7 +97,7 @@ fi
kube::log::status "Updating " "${OPENAPI_ROOT_DIR}"
curl -w "\n" -kfs --oauth2-bearer dummy_token "https://${API_HOST}:${API_PORT}/openapi/v2" | jq -S '.info.version="unversioned"' > "${OPENAPI_ROOT_DIR}/swagger.json"
curl -w "\n" -kfsS -H 'Authorization: Bearer dummy_token' "https://${API_HOST}:${API_PORT}/openapi/v2" | jq -S '.info.version="unversioned"' > "${OPENAPI_ROOT_DIR}/swagger.json"
kube::log::status "SUCCESS"