Skip to content

Commit

Permalink
chore: generate random file to store output for stencil-push script
Browse files Browse the repository at this point in the history
  • Loading branch information
h4rikris committed Jun 3, 2021
1 parent 61ffe8e commit 528d6df
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions stencil-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ curl -sS -w "\n" -u $STENCIL_USERNAME:$STENCIL_PASSWORD -X PUT --fail "https://$

ACTION="Upload proto descriptor to stencil service with version number: $project_version"
log_info $ACTION
http_response=$(curl -s -o /tmp/stencil_out.txt -w "%{http_code}" -u $STENCIL_USERNAME:$STENCIL_PASSWORD -X POST "https://$STENCIL_HOSTNAME/v1/descriptors" -F "file=@$file_path" -F "version=$project_version" -F "name=$proto_repo" -F "latest=true" -H "Content-Type: multipart/form-data")
response_filename="/tmp/stencil_out_$( cat /dev/urandom | base64 | tr -cd 'a-f0-9' | head -c 16 ).txt"
http_response=$(curl -s -o $response_filename -w "%{http_code}" -u $STENCIL_USERNAME:$STENCIL_PASSWORD -X POST "https://$STENCIL_HOSTNAME/v1/descriptors" -F "file=@$file_path" -F "version=$project_version" -F "name=$proto_repo" -F "latest=true" -H "Content-Type: multipart/form-data")
if [ $? != 0 ]; then
log_error "curl request failed"
exit 1
elif [[ $http_response =~ ^[4-5][0-9][0-9]$ ]]; then
log_error "status_code:" $http_response
log_error $(cat /tmp/stencil_out.txt)
rm /tmp/stencil_out.txt
log_error $(cat $response_filename)
rm $response_filename
exit 1
fi
trap - EXIT

0 comments on commit 528d6df

Please sign in to comment.