Support specifying a Kayobe environment to use
This also includes a cherry-pick of I9a44578196086ec24de80b992fed385826778feb, Stop accessing unbound variables. The kayobe-env script would try accessing $1 which is an unbound variable if no argument is passed. This fails when `set -u` is set. Also refactor usage output into a function. As a side effect, a missing argument to --environment now causes the script to properly exit with an error. Change-Id: I604c2ae6c47ef16fdc98e0598cad820e49e2ff26 Story: 2002009 Task: 41577 (cherry picked from commit 75b6402f8b0d4e39c40a1d11091ca760d8b99dee)
This commit is contained in:
parent
fc527165e2
commit
f1d98a9394
27
kayobe-env
27
kayobe-env
@ -35,3 +35,30 @@ export KOLLA_SOURCE_PATH=${KOLLA_SOURCE_PATH:-${base_path}/src/kolla-ansible}
|
||||
# NOTE: This should not be in the Vagrant shared directory, as there are
|
||||
# issues with symlinks on Windows hosts.
|
||||
export KOLLA_VENV_PATH=~/kolla-venv
|
||||
|
||||
function usage {
|
||||
echo "usage: ${BASH_SOURCE[0]:-${(%):-%x}} [--environment <env-name>]"
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ "$#" -ge 1 ]; then
|
||||
if [ "$1" = "--environment" -a "$#" -eq 2 ]; then
|
||||
kayobe_env="$2"
|
||||
# Look for existing Kayobe environments
|
||||
if [ -d "${KAYOBE_CONFIG_PATH}/environments" ]; then
|
||||
if [ -d "${KAYOBE_CONFIG_PATH}/environments/${kayobe_env}" ]; then
|
||||
export KAYOBE_ENVIRONMENT="${kayobe_env}"
|
||||
echo "Using Kayobe environment ${KAYOBE_ENVIRONMENT}"
|
||||
return 0
|
||||
else
|
||||
echo "Unable to find Kayobe environment ${kayobe_env} in ${KAYOBE_CONFIG_PATH}/environments"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "Cannot find environments folder in ${KAYOBE_CONFIG_PATH}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
usage
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user