From e00cd1f3fd91521d89660ef7d4eb1d02fcef57cb Mon Sep 17 00:00:00 2001 From: pkrishn1-pk <58206553+pkrishn1-pk@users.noreply.github.com> Date: Tue, 3 Mar 2020 12:21:44 +0530 Subject: [PATCH] check if token contains bearer header or not --- scripts/delete_custom_image.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/delete_custom_image.sh b/scripts/delete_custom_image.sh index bec1944..b206b6c 100644 --- a/scripts/delete_custom_image.sh +++ b/scripts/delete_custom_image.sh @@ -55,9 +55,13 @@ function delete_image() { _log "## Entering function: ${FUNCNAME[0]}" # Command to delete Custom Image from user account. # IC_IAM_TOKEN - Provided by IBM Cloud Schematics + token=$IC_IAM_TOKEN + if [[ $token != Bearer* ]]; then + token="Bearer "$token + fi curl -X DELETE \ "$rias_endpoint/v1/images/$custom_image_id?version=2020-01-28&generation=2" \ - -H "Authorization: Bearer $IC_IAM_TOKEN" &> "$MSG_FILE" + -H "Authorization: $token" &> "$MSG_FILE" _log "## Exiting function: ${FUNCNAME[0]}" }