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>
test1
Valentin Lab 5 years ago
parent
commit
9f38ef9bb9
  1. 33
      bin/compose

33
bin/compose

@ -454,6 +454,17 @@ mk_docker_run_options() {
mkdir -p "$COMPOSE_VAR"/sessions mkdir -p "$COMPOSE_VAR"/sessions
mv "$filename" "$dest" mv "$filename" "$dest"
echo "$dest" echo "$dest"
if [ "$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"
fi >&2
} }
@ -496,6 +507,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() { run() {
local os docker_run_opts local os docker_run_opts
@ -519,6 +544,14 @@ run() {
[ -t 0 ] && docker_run_opts+=("-i") [ -t 0 ] && docker_run_opts+=("-i")
[ -t 1 ] && docker_run_opts+=("-t") [ -t 1 ] && docker_run_opts+=("-t")
if [ "$DEBUG" ]; then
echo "${WHITE}Launching:${NORMAL}"
echo " docker run --rm \\"
pretty_print "${docker_run_opts[@]}" | sed -r 's/^/ /g' >&2
echo "\\"$'\n' >&2
echo " ${COMPOSE_DOCKER_IMAGE} \\"
echo " " "$@"
fi >&2
exec docker run --rm "${docker_run_opts[@]}" "${COMPOSE_DOCKER_IMAGE}" "$@" exec docker run --rm "${docker_run_opts[@]}" "${COMPOSE_DOCKER_IMAGE}" "$@"
} }

Loading…
Cancel
Save