deploy.sh: assigning function param to named variable

This commit is contained in:
2017-01-12 16:55:40 +01:00
parent a488ff4176
commit 0b6584e5b1

View File

@@ -22,29 +22,29 @@ if [ -n "$(git log origin/production..production --oneline)" ]; then
read dummy read dummy
fi fi
# Find Module
function find_module() function find_module()
{ {
MODULE_NAME=$1
MODULE_DIR=$(python <<EOT MODULE_DIR=$(python <<EOT
from __future__ import print_function from __future__ import print_function
import os.path import os.path
try: try:
import $1 import ${MODULE_NAME}
except ImportError: except ImportError:
raise SystemExit('${1^} not found on Python path. Are you in the correct venv?') raise SystemExit('${MODULE_NAME} not found on Python path. Are you in the correct venv?')
print(os.path.dirname(os.path.dirname($1))) print(os.path.dirname(os.path.dirname(${MODULE_NAME}.__file__)))
EOT EOT
) )
if [ $(git -C $MODULE_DIR rev-parse --abbrev-ref HEAD) != "production" ]; then if [ $(git -C $MODULE_DIR rev-parse --abbrev-ref HEAD) != "production" ]; then
echo "${1^} ($MODULE_DIR) NOT on the production branch, refusing to deploy." >&2 echo "${MODULE_NAME}: ($MODULE_DIR) NOT on the production branch, refusing to deploy." >&2
exit 1 exit 1
fi fi
}
# Find Pillar # Find Pillar
find_module pillar find_module pillar
}
# Find Attract # Find Attract
find_module attract find_module attract