File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,17 @@ fetch_data() {
4848
4949 while [ " $url " != " null" ]; do
5050 # Fetch data from the API
51- response =$( curl -s " $url " --header " Authorization: $IAM_TOKEN " --header " Content-Type: application/json" )
51+ IAM_RESPONSE =$( curl -s " $url " --header " Authorization: $IAM_TOKEN " --header " Content-Type: application/json" )
5252
53- # Extract next URL and current data
54- next_url=$( echo " $response " | jq -r ' .next' )
55- key_descriptions=$( echo " $response " | jq -r --arg name " ${APIKEY_KEY_NAME} " ' .apikeys | .[] | select(.name == $name) | .description' )
53+ ERROR_MESSAGE=$( echo " ${IAM_RESPONSE} " | jq ' has("errors")' )
54+ if [[ " ${ERROR_MESSAGE} " != false ]]; then
55+ echo " ${IAM_RESPONSE} " | jq ' .errors'
56+ echo " Could not obtain api keys"
57+ exit 1
58+ fi
59+
60+ next_url=$( echo " ${IAM_RESPONSE} " | jq -r ' .next' )
61+ key_descriptions=$( echo " $IAM_RESPONSE " | jq -r --arg name " ${APIKEY_KEY_NAME} " ' .apikeys | .[] | select(.name == $name) | .description' )
5662 for i in " ${key_descriptions[@]} " ; do
5763 if [[ " $i " =~ ${REGION} ]] && [[ " $i " =~ ${RESOURCE_GROUP_ID} ]]; then
5864 echo " Found key named ${APIKEY_KEY_NAME} which covers clusters in ${REGION} and resource group ID ${RESOURCE_GROUP_ID} "
You can’t perform that action at this time.
0 commit comments