From a024649a5f1ae630492c5b4d48b1872d83919a18 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 12 Nov 2018 16:17:40 +0100 Subject: [PATCH] new: ``compose config`` on validation success outputs the final docker-compose file on standard output instead of standard error. --- bin/compose | 7 ++++++- test/base | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/bin/compose b/bin/compose index 4ac1cfc..96e6459 100755 --- a/bin/compose +++ b/bin/compose @@ -2960,7 +2960,12 @@ case "$action" in config) ## removing the services services=($(get_master_services "${action_posargs[@]}")) || exit 1 - launch_docker_compose "${compose_opts[@]}" "$action" "${action_opts[@]}" "${remainder_args[@]}" + ## forcing docker-compose config to output the config file to stdout and not stderr + out=$(launch_docker_compose "${compose_opts[@]}" "$action" "${action_opts[@]}" "${remainder_args[@]}" 2>&1) || { + echo "$out" + exit 1 + } + echo "$out" warn "Runtime configuration modification (from relations) are not included here." ;; down) diff --git a/test/base b/test/base index 15b2e23..3850c47 100755 --- a/test/base +++ b/test/base @@ -1243,7 +1243,22 @@ EOF2 cd "$test_tmpdir" export DISABLE_SYSTEM_CONFIG_FILE=true -"$tprog" config +out=\$("$tprog" config) || exit 1 +expected="networks: + static: + driver: bridge + ipam: + config: + - subnet: 172.25.1.0/24 + driver: default +services: {} +version: '2.0'" + +[ "\$out" == "\$expected" ] || { + echo -e "DIFF:\n\$(diff <(echo "\$out") <(echo "\$expected"))" + exit 1 +} + ## -- simple service provided