@@ -1628,9 +1628,8 @@ function slack() {
16281628 )
16291629
16301630 debug " sending slack message with payload: %s" " ${payload} "
1631- if ! curl -SsL --fail -X POST -H " Content-Type: application/json" -d " ${payload} " " ${webhook} " ; then
1632- echo " ERROR: Failed to send slack notification" >&2
1633- fi
1631+ wrap curl -SsL --fail -X POST -H " Content-Type: application/json" -d " ${payload} " " ${webhook} " \
1632+ " Failed to send slack notification"
16341633}
16351634
16361635# Install internal HashiCorp tools. These tools are expected to
@@ -1911,7 +1910,7 @@ function github_release_assets() {
19111910
19121911 github_request " ${req_args[@]} " -o " ${artifact} " " ${asset} " ||
19131912 " Failed to download asset (${artifact} ) in release ${release_name} for ${repository} "
1914- printf " downloaded release asset %s from release %s on %s" " ${artifact} " " ${release_name} " " ${repository} "
1913+ printf " downloaded release asset %s from release %s on %s\n " " ${artifact} " " ${release_name} " " ${repository} "
19151914 done
19161915
19171916 repository=" ${repository_bak} " # restore the repository value
@@ -3008,6 +3007,7 @@ function github_request() {
30083007 fi
30093008
30103009 local ratelimit_reset
3010+ local ratelimit_remaining
30113011 local response_content=" "
30123012
30133013 # Read the response into lines for processing
@@ -3041,6 +3041,10 @@ function github_request() {
30413041 ratelimit_reset=" ${line##* ratelimit-reset: } "
30423042 debug " ratelimit reset time found: %s" " ${ratelimit_reset} "
30433043 fi
3044+ if [[ " ${line} " == " x-ratelimit-remaining" * ]]; then
3045+ ratelimit_remaining=" ${line##* ratelimit-remaining: } "
3046+ debug " ratelimit requests remaining: %d" " ${ratelimit_remaining} "
3047+ fi
30443048 done
30453049
30463050 # If the status was not detected, force an error
@@ -3062,12 +3066,16 @@ function github_request() {
30623066
30633067 # If the ratelimit reset was not detected force an error
30643068 if [ -z " ${ratelimit_reset} " ]; then
3065- if [ " ${status} " = " 403" ]; then
3066- failure " Request failed with 403 status response"
3067- fi
30683069 failure " Failed to detect rate limit reset time for GitHub request"
30693070 fi
30703071
3072+ # If there are requests still available against the ratelimt
3073+ # and the status is a 403, then it's an actual 403 and not
3074+ # a ratelimit
3075+ if [[ " ${status} " = " 403" ]] && [[ " ${ratelimit_remaining} " -gt 0 ]]; then
3076+ failure " Request failed with 403 status response"
3077+ fi
3078+
30713079 debug " rate limiting has been detected on request"
30723080
30733081 local reset_date
0 commit comments