svn commit: r318190 - head/release/scripts
Glen Barber
gjb at FreeBSD.org
Thu May 11 16:37:31 UTC 2017
Author: gjb
Date: Thu May 11 16:37:29 2017
New Revision: 318190
URL: https://svnweb.freebsd.org/changeset/base/318190
Log:
Update release/scripts/atlas-upload.sh to account for API changes
made recently by Atlas Hashicorp. The data returned from GET and
POST requests has changed, which caused a number of regex patterns
to fail to be properly identified as 'success' or 'failure', which
ended up in upload/publish failures.
Tested with: 12-CURRENT
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Modified:
head/release/scripts/atlas-upload.sh
Modified: head/release/scripts/atlas-upload.sh
==============================================================================
--- head/release/scripts/atlas-upload.sh Thu May 11 16:26:56 2017 (r318189)
+++ head/release/scripts/atlas-upload.sh Thu May 11 16:37:29 2017 (r318190)
@@ -132,20 +132,20 @@ main () {
echo "Failed to get the token from the API"
exit 2;
fi
- echo ${TOKENRESULT} | grep "\"token\":" > /dev/null
+ echo ${TOKENRESULT} | grep -E "\"(token|upload_path)\":" > /dev/null
if [ $? != 0 ]; then
echo "No token found from the API"
exit 2
else
- TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/".*//')
+ TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/.*upload_path":"//' -e 's/}$//g' -e 's/"//g')
echo "Uploading to Atlas"
- UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${ATLAS_UPLOAD_URL}/${TOKEN})
+ UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${TOKEN})
# Validate the Upload
echo "Validating"
VALIDRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
- HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*hosted_token":"//' -e 's/".*//')
- if [ ! -z ${HOSTED_TOKEN} -a ! -z ${TOKEN} -a ${HOSTED_TOKEN} != ${TOKEN} ]; then
+ HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*"hosted"://' -e 's/,.*$//')
+ if [ ! -z ${TOKEN} -a "${HOSTED_TOKEN}" != "true" ]; then
echo "Upload failed, try again."
exit 2
fi
More information about the svn-src-head
mailing list