Support reading Kayobe environment name from file
If using separate branches for each environment, it can be useful to read the environment name from a file committed to each branch. Or, if sharing the same branch for all environments, it can be useful to set the default environment to one with lower impact, e.g. dev or staging. If no --environment option is specified and a .environment file exists at the root of the directory, use its content as KAYOBE_ENVIRONMENT. Change-Id: I22b2b466e47a3b4d96931d754a4de7544f0ada5d (cherry picked from commit 2af2c3a3b5387c577801b165ecd749fe782fddb9)
This commit is contained in:
parent
f1d98a9394
commit
df9ae70899
26
kayobe-env
26
kayobe-env
@ -36,14 +36,7 @@ export KOLLA_SOURCE_PATH=${KOLLA_SOURCE_PATH:-${base_path}/src/kolla-ansible}
|
|||||||
# issues with symlinks on Windows hosts.
|
# issues with symlinks on Windows hosts.
|
||||||
export KOLLA_VENV_PATH=~/kolla-venv
|
export KOLLA_VENV_PATH=~/kolla-venv
|
||||||
|
|
||||||
function usage {
|
function check_and_export_env {
|
||||||
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
|
# Look for existing Kayobe environments
|
||||||
if [ -d "${KAYOBE_CONFIG_PATH}/environments" ]; then
|
if [ -d "${KAYOBE_CONFIG_PATH}/environments" ]; then
|
||||||
if [ -d "${KAYOBE_CONFIG_PATH}/environments/${kayobe_env}" ]; then
|
if [ -d "${KAYOBE_CONFIG_PATH}/environments/${kayobe_env}" ]; then
|
||||||
@ -58,7 +51,24 @@ if [ "$#" -ge 1 ]; then
|
|||||||
echo "Cannot find environments folder in ${KAYOBE_CONFIG_PATH}"
|
echo "Cannot find environments folder in ${KAYOBE_CONFIG_PATH}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
check_and_export_env
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "$KAYOBE_CONFIG_ROOT/.environment" ]]; then
|
||||||
|
kayobe_env=$(cat "$KAYOBE_CONFIG_ROOT/.environment")
|
||||||
|
check_and_export_env
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user