Browse Source

fix: [compose-core] make ``compose`` return action's errorlevel

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
master
Valentin Lab 2 years ago
parent
commit
56db0aaf13
  1. 16
      bin/compose-core

16
bin/compose-core

@ -720,7 +720,7 @@ export -f set_db_params
export _PID="$$"
ensure_db_docker_running () {
local _STATE_FILE
local _STATE_FILE errlvl
_DB_NAME="db_${DB_NAME}_${_PID}"
_STATE_FILE="$state_tmpdir/${_DB_NAME}.state"
@ -1891,6 +1891,7 @@ export -f logstderr
_run_service_relation () {
local relation_name="$1" service="$2" target_service="$3" relation_config="$4" relation_dir services
local errlvl
charm=$(get_service_charm "$service") || return 1
target_charm=$(get_service_charm "$target_service") || return 1
@ -2269,7 +2270,7 @@ export -f _get_services_provides
_get_charm_provides() {
local cache_file="$CACHEDIR/$FUNCNAME.cache.$(charm.store_metadata_hash)"
local cache_file="$CACHEDIR/$FUNCNAME.cache.$(charm.store_metadata_hash)" errlvl
if [ -e "$cache_file" ]; then
#debug "$FUNCNAME: SESSION cache hit"
cat "$cache_file"
@ -2810,7 +2811,7 @@ export -f has_service_action
run_service_action () {
local service="$1" action="$2"
local service="$1" action="$2" errlvl
shift ; shift
exec 6<&0 ## saving stdin
{
@ -2821,9 +2822,12 @@ run_service_action () {
fi
"_run_service_action_${action_type}" "$service" "$action" "$@"
errlvl="$?"
} < <(has_service_action "$service" "$action")
exec 0<&6 6<&- ## restoring stdin
return "$errlvl"
}
export -f run_service_action
@ -4213,6 +4217,7 @@ export SERVICE_PACK="${services_args[*]}"
## Docker-compose
##
errlvl="0"
case "$action" in
up|start|stop|build|run)
## force daemon mode for up
@ -4259,6 +4264,7 @@ case "$action" in
*)
if [ "$is_service_action" ]; then
run_service_action "$SERVICE_PACK" "$action" "${remainder_args[@]}"
errlvl="$?"
else
launch_docker_compose "${compose_opts[@]}" "$action" "${action_opts[@]}" "${action_posargs[@]}" "${remainder_args[@]}"
fi
@ -4276,4 +4282,6 @@ if [ "$action" == "run" -a "${#services_args}" != 0 ]; then
fi
fi
clean_unused_docker_compose || return 1
clean_unused_docker_compose || exit 1
exit "$errlvl"
Loading…
Cancel
Save