Created
January 17, 2017 17:08
-
-
Save cedricvidal/f43bbead614d10bc70be12a93c09c5c4 to your computer and use it in GitHub Desktop.
Load OpenStack OS_* env variables automatically using direnv and envchain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layout python | |
PATH_add bin | |
ENVCHAIN_NS=qs-ovh-cloud | |
if [ -z "$OS_PASSWORD" ]; then | |
if type envchain > /dev/null; then | |
echo "Loading OS_PASSWORD env var from keychain" | |
direnv_load envchain $ENVCHAIN_NS direnv dump | |
else | |
echo | |
echo "|--------------------------------------------------------------------------------------------|" | |
echo "| You could store the password in the keychain to avoid typing the password, using envchain: |" | |
echo "| brew install envchain |" | |
echo "| envchain --set $ENVCHAIN_NS OS_PASSWORD |" | |
echo "|--------------------------------------------------------------------------------------------|" | |
echo | |
fi | |
fi | |
if [ -f openrc.sh ]; then | |
# Loads openrc.sh but disables all password related stuff to avoid blocking | |
echo "Loading OS_* env vars from openrc.sh" | |
direnv_load bash -c "source <(cat openrc.sh | grep -vi password); direnv dump" | |
else | |
echo | |
echo "|------------------------------------------------------------------------|" | |
echo "| Openstack openrc.sh does not exist, you could create an openrc.sh file |" | |
echo "| exporting all OS_* env variables to automate the process of defining |" | |
echo "| OS_* variables. It would be loaded by direnv automatically |" | |
echo "|------------------------------------------------------------------------|" | |
echo | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment