Browse Source

new: dev: debug messages on launcher

Using ``DEBUG=1`` on binary compose docker launcher prints
pretty-printed docker command launched as well as important
system variables.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
lokavaluto/dev/master
Valentin Lab 5 years ago
parent
commit
00b4206fc6
  1. 38
      bin/compose

38
bin/compose

@ -446,9 +446,22 @@ mk_docker_run_options() {
p0 "-e" "COMPOSE_LAUNCHER_OPTS=$dest"
p0 "-e" "COMPOSE_LAUNCHER_BIN=$COMPOSE_LAUNCHER_BIN"
} >> "$filename"
mkdir -p "$SESSION_DIR" || return 1
mv -f "$filename" "$SESSION_DIR/$UID-$sha" || return 1
echo "$SESSION_DIR/$UID-$sha"
if [ -n "$DEBUG" ]; then
echo "${WHITE}Environment:${NORMAL}"
echo " COMPOSE_DOCKER_IMAGE: $COMPOSE_DOCKER_IMAGE"
echo " CHARM_STORE: $CHARM_STORE"
echo " DATASTORE: $DATASTORE"
echo " CONFIGSTORE: $CONFIGSTORE"
echo " COMPOSE_VAR: $COMPOSE_VAR"
echo " COMPOSE_CACHE: $COMPOSE_CACHE"
echo " SESSION_DIR: $SESSION_DIR"
echo " TZ_PATH: $TZ_PATH"
fi >&2
}
@ -491,6 +504,20 @@ get_tz() {
}
pretty_print() {
while [ "$#" != 0 ]; do
case "$1" in
"-v"|"-e"|"-w")
e "$1" "$2" "\\"$'\n'
shift;;
*)
e "$1 ";;
esac
shift
done
}
run() {
local os docker_run_opts
@ -514,7 +541,18 @@ run() {
[ -t 0 ] && docker_run_opts+=("-i")
[ -t 1 ] && docker_run_opts+=("-t")
if [ -n "$DEBUG" ] || [ -n "$DRY_RUN" ]; then
debug "${WHITE}Launching:${NORMAL}"
echo "docker run --rm \\"
pretty_print "${docker_run_opts[@]}" | sed -r 's/^/ /g;s/([^\])$/\1\\\n/g'
echo " ${COMPOSE_DOCKER_IMAGE} \\"
echo " " "$@"
fi | { if [ -n "$DEBUG" ]; then sed -r 's/^/ /g'; else cat; fi } >&2
if [ -z "$DRY_RUN" ]; then
debug "${WHITE}Execution:${NORMAL}"
exec docker run --rm "${docker_run_opts[@]}" "${COMPOSE_DOCKER_IMAGE}" "$@"
fi
}

Loading…
Cancel
Save