Skip to content

Instantly share code, notes, and snippets.

@jt-nti
Created July 9, 2018 16:17
Show Gist options
  • Save jt-nti/206a1fcb40e0f96c17e856ee4a076723 to your computer and use it in GitHub Desktop.
Save jt-nti/206a1fcb40e0f96c17e856ee4a076723 to your computer and use it in GitHub Desktop.
Experimental function to get a deploy name that's unlikely to collide on IBM Cloud
#!/bin/bash
function get_deploy_name {
uuid="$1"
shift
old_ifs="$IFS"
IFS='_'
name="$*"
IFS=$old_ifs
unique_name="${name}_${uuid}"
short_hash=$(echo ${unique_name} | git hash-object --stdin | head -c 7)
deploy_name="$(echo ${name} | head -c 43)${short_hash}"
echo $deploy_name
}
echo $(get_deploy_name $(uuidgen) blockchain-20180709151348280 some-deployable-thing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment