dk: rendre le code overridable
This commit is contained in:
parent
aae3703558
commit
269379f3a2
76
dk
76
dk
|
@ -1231,24 +1231,7 @@ EOF
|
|||
local_run "$HOST" "$tmpscript"
|
||||
}
|
||||
|
||||
function auto_composer() {
|
||||
local COMPOSER_IMAGE="$DEFAULT_COMPOSER_IMAGE"
|
||||
local COMPOSER_MACHINE=-u
|
||||
local COMPOSER_CMD=
|
||||
local COMPOSER_SETUP=
|
||||
[ -f .composer.conf ] && source ./.composer.conf
|
||||
# les premiers arguments peuvent service à redéfinir les variables
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
COMPOSER_IMAGE=*) setv "$1"; shift;;
|
||||
COMPOSER_MACHINE=*) setv "$1"; shift;;
|
||||
COMPOSER_CMD=*) setv "$1"; shift;;
|
||||
COMPOSER_SETUP=*) setv "$1"; shift;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$COMPOSER_IMAGE" == none ]; then
|
||||
function default_local_composer() {
|
||||
# lancement direct
|
||||
case "$1" in
|
||||
rootshell|shell|rootbash|bash)
|
||||
|
@ -1271,21 +1254,9 @@ function auto_composer() {
|
|||
"$COMPOSER_CMD" "$@"
|
||||
;;
|
||||
esac
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ -n "$COMPOSER_MACHINE" -a "$DOCKER_MACHINE_NAME" != "$COMPOSER_MACHINE" ]; then
|
||||
local -x DOCKER_TLS_VERIFY= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_MACHINE_NAME=
|
||||
if [ "$COMPOSER_MACHINE" != -u ]; then
|
||||
local env
|
||||
setx env=docker-machine env "$COMPOSER_MACHINE" 2>/dev/null || {
|
||||
eerror "$COMPOSER_MACHINE: une erreur s'est produite lors de la sélection du noeud avec docker-machine"
|
||||
return 1
|
||||
}
|
||||
eval "$env"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
function default_docker_composer() {
|
||||
# lancement dans un container
|
||||
local user group projdir actualcmd args
|
||||
setx user=id -un; setx user=getent passwd "$user"
|
||||
setx group=id -gn; setx group=getent group "$group"
|
||||
|
@ -1375,6 +1346,45 @@ fi
|
|||
)
|
||||
"${cmd[@]}"
|
||||
}
|
||||
function local_composer() { default_local_composer "$@"; }
|
||||
function docker_composer() { default_docker_composer "$@"; }
|
||||
function auto_composer() {
|
||||
local COMPOSER_IMAGE="$DEFAULT_COMPOSER_IMAGE"
|
||||
local COMPOSER_MACHINE=-u
|
||||
local COMPOSER_CMD=
|
||||
local COMPOSER_SETUP=
|
||||
[ -f .composer.conf ] && source ./.composer.conf
|
||||
# les premiers arguments peuvent service à redéfinir les variables
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
COMPOSER_IMAGE=*) setv "$1"; shift;;
|
||||
COMPOSER_MACHINE=*) setv "$1"; shift;;
|
||||
COMPOSER_CMD=*) setv "$1"; shift;;
|
||||
COMPOSER_SETUP=*) setv "$1"; shift;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$COMPOSER_IMAGE" == none ]; then
|
||||
local_composer "$@"
|
||||
|
||||
else
|
||||
local PREVIOUS_DOCKER_MACHINE_NAME="$DOCKER_MACHINE_NAME"
|
||||
if [ -n "$COMPOSER_MACHINE" -a "$DOCKER_MACHINE_NAME" != "$COMPOSER_MACHINE" ]; then
|
||||
local -x DOCKER_TLS_VERIFY= DOCKER_HOST= DOCKER_CERT_PATH= DOCKER_MACHINE_NAME=
|
||||
if [ "$COMPOSER_MACHINE" != -u ]; then
|
||||
local env
|
||||
setx env=docker-machine env "$COMPOSER_MACHINE" 2>/dev/null || {
|
||||
eerror "$COMPOSER_MACHINE: une erreur s'est produite lors de la sélection du noeud avec docker-machine"
|
||||
return 1
|
||||
}
|
||||
eval "$env"
|
||||
fi
|
||||
fi
|
||||
|
||||
docker_composer "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################################
|
||||
|
||||
|
|
Loading…
Reference in New Issue