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
1 changed files with 49 additions and 28 deletions

77
dk
View File

@ -87,6 +87,11 @@ OPTIONS générales
(ces options sont communes à toutes les commandes)
-d, --chdir PROJDIR
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, --prod
-T, --test
@ -232,42 +237,56 @@ function compose_set_project_name() {
fi
}
function compose_set_env_args() {
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_env_args+=(-f docker-stack.yml)
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
replace_env_args+=(-f docker-compose.yml)
fi
if [ -n "$USE_STACK" -a -f docker-stack.override.yml ]; then
replace_env_args+=(-f docker-stack.override.yml)
elif [ -f docker-compose.override.yml ]; then
replace_env_args+=(-f docker-compose.override.yml)
fi
if [ -n "$PROFILE" ]; then
if [ -n "$USE_STACK" -a -f "docker-stack.$PROFILE.yml" ]; then
replace_env_args+=(-f "docker-stack.$PROFILE.yml")
elif [ -f "docker-compose.$PROFILE.yml" ]; then
replace_env_args+=(-f "docker-compose.$PROFILE.yml")
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_env_args+=(-f docker-stack.yml)
else
replace_env_args+=(-f docker-compose.yml)
fi
if [ -n "$USE_STACK" -a -f docker-stack.override.yml ]; then
replace_env_args+=(-f docker-stack.override.yml)
elif [ -f docker-compose.override.yml ]; then
replace_env_args+=(-f docker-compose.override.yml)
fi
if [ -n "$PROFILE" ]; then
if [ -n "$USE_STACK" -a -f "docker-stack.$PROFILE.yml" ]; then
replace_env_args+=(-f "docker-stack.$PROFILE.yml")
elif [ -f "docker-compose.$PROFILE.yml" ]; then
replace_env_args+=(-f "docker-compose.$PROFILE.yml")
fi
fi
fi
compose_set_project_name "$@"
}
function docker_set_deploy_args() {
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_deploy_args+=(-c docker-stack.yml)
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
replace_deploy_args+=(-c docker-compose.yml)
fi
if [ -n "$USE_STACK" -a -f docker-stack.override.yml ]; then
replace_deploy_args+=(-c docker-stack.override.yml)
elif [ -f docker-compose.override.yml ]; then
replace_deploy_args+=(-c docker-compose.override.yml)
fi
if [ -n "$PROFILE" ]; then
if [ -n "$USE_STACK" -a -f "docker-stack.$PROFILE.yml" ]; then
replace_deploy_args+=(-c "docker-stack.$PROFILE.yml")
elif [ -f "docker-compose.$PROFILE.yml" ]; then
replace_deploy_args+=(-c "docker-compose.$PROFILE.yml")
if [ -n "$USE_STACK" -a -f docker-stack.yml ]; then
replace_deploy_args+=(-c docker-stack.yml)
else
replace_deploy_args+=(-c docker-compose.yml)
fi
if [ -n "$USE_STACK" -a -f docker-stack.override.yml ]; then
replace_deploy_args+=(-c docker-stack.override.yml)
elif [ -f docker-compose.override.yml ]; then
replace_deploy_args+=(-c docker-compose.override.yml)
fi
if [ -n "$PROFILE" ]; then
if [ -n "$USE_STACK" -a -f "docker-stack.$PROFILE.yml" ]; then
replace_deploy_args+=(-c "docker-stack.$PROFILE.yml")
elif [ -f "docker-compose.$PROFILE.yml" ]; then
replace_deploy_args+=(-c "docker-compose.$PROFILE.yml")
fi
fi
fi
@ -906,6 +925,7 @@ set_defaults dk
export PROFILE
chdir=
CONFIG=
DM_SET_MACHINE=
USE_STACK=
FAKE=
@ -918,6 +938,7 @@ update_apps_branch=
args=(
--help '$exit_with display_help'
-d:,--chdir: chdir=
-c:,--config: CONFIG=
-p:,--profile: PROFILE=
-P,--prod PROFILE=prod
-T,--test PROFILE=test