dk: support de fichiers compose non défaut

This commit is contained in:
Jephté Clain 2019-06-11 08:06:29 +04:00
parent 7e5859eee5
commit a5a41d9b1e

21
dk
View File

@ -87,6 +87,11 @@ OPTIONS générales
(ces options sont communes à toutes les commandes) (ces options sont communes à toutes les commandes)
-d, --chdir PROJDIR -d, --chdir PROJDIR
Spécifier le répertoire du projet Spécifier le répertoire du projet
-c, --config config.yml
Spécifier le fichier de configuration à utiliser. le fichier de profil
config.PROFILE.yml est chargé aussi s'il existe.
Si cette option n'est pas spécifiée, docker-compose.yml est utilisé par
défaut (ou avec l'option --stack docker-stack.yml s'il existe)
-p, --profile PROFILE -p, --profile PROFILE
-P, --prod -P, --prod
-T, --test -T, --test
@ -232,6 +237,12 @@ function compose_set_project_name() {
fi fi
} }
function compose_set_env_args() { function compose_set_env_args() {
if [ -n "$CONFIG" ]; then
replace_env_args+=(-f "$CONFIG")
if [ -n "$PROFILE" -a -f "${CONFIG%.yml}.$PROFILE.yml" ]; then
replace_env_args+=(-f "${CONFIG%.yml}.$PROFILE.yml")
fi
else
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_env_args+=(-f docker-stack.yml) replace_env_args+=(-f docker-stack.yml)
else else
@ -249,10 +260,17 @@ function compose_set_env_args() {
replace_env_args+=(-f "docker-compose.$PROFILE.yml") replace_env_args+=(-f "docker-compose.$PROFILE.yml")
fi fi
fi fi
fi
compose_set_project_name "$@" compose_set_project_name "$@"
} }
function docker_set_deploy_args() { function docker_set_deploy_args() {
if [ -n "$CONFIG" ]; then
replace_deploy_args+=(-c "$CONFIG")
if [ -n "$PROFILE" -a -f "${CONFIG%.yml}.$PROFILE.yml" ]; then
replace_deploy_args+=(-c "${CONFIG%.yml}.$PROFILE.yml")
fi
else
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_deploy_args+=(-c docker-stack.yml) replace_deploy_args+=(-c docker-stack.yml)
else else
@ -270,6 +288,7 @@ function docker_set_deploy_args() {
replace_deploy_args+=(-c "docker-compose.$PROFILE.yml") replace_deploy_args+=(-c "docker-compose.$PROFILE.yml")
fi fi
fi fi
fi
compose_set_project_name "$@" compose_set_project_name "$@"
} }
@ -906,6 +925,7 @@ set_defaults dk
export PROFILE export PROFILE
chdir= chdir=
CONFIG=
DM_SET_MACHINE= DM_SET_MACHINE=
USE_STACK= USE_STACK=
FAKE= FAKE=
@ -918,6 +938,7 @@ update_apps_branch=
args=( args=(
--help '$exit_with display_help' --help '$exit_with display_help'
-d:,--chdir: chdir= -d:,--chdir: chdir=
-c:,--config: CONFIG=
-p:,--profile: PROFILE= -p:,--profile: PROFILE=
-P,--prod PROFILE=prod -P,--prod PROFILE=prod
-T,--test PROFILE=test -T,--test PROFILE=test