Strip extra '-' from md5sum output when creating S3 bucket

md5sum prints out the hash, followed by the filename. When piped in from
stdin, this equates to a '-' character.

cluster/aws/util.sh was incorrect including this '-' character as part
of the S3 bucket name, causing the script to fail on Linux machines with
the md5sum binary.

i.e. "s3://kubernetes-staging-0ac68d8c77915cc1069a9e2f5e1f1d2d -"

Fixed by using `awk` to return only the first column (up to the space)
This commit is contained in:
James Davies 2014-11-12 16:56:50 +10:00
parent 797c499b59
commit 945339362f

View File

@ -162,7 +162,7 @@ function upload-server-tars() {
if which md5 > /dev/null 2>&1; then
project_hash=$(md5 -q -s "${USER} ${key}")
else
project_hash=$(echo -n "${USER} ${key}" | md5sum)
project_hash=$(echo -n "${USER} ${key}" | md5sum | awk '{ print $1 }')
fi
local -r staging_bucket="kubernetes-staging-${project_hash}"