diff --git a/bin/compose b/bin/compose index 96e6459..5d714f2 100755 --- a/bin/compose +++ b/bin/compose @@ -2218,6 +2218,7 @@ get_compose_yml_content() { COMPOSE_YML_CONTENT="" fi + COMPOSE_YML_CONTENT=$(merge_yaml_str "$COMPOSE_YML_CONTENT" "${compose_contents[@]}") || return 1 output=$(echo "$COMPOSE_YML_CONTENT"| shyaml get-value 2>&1) if [ "$?" != 0 ]; then outputed_something= @@ -2437,6 +2438,8 @@ display_help() { echo " command line will be used." echo " --rebuild-relations-to-service, -R SERVICE" echo " Will rebuild all relations to given service" + echo " --add-compose-content, -Y YAML" + echo " Will merge some direct YAML with the current compose" get_docker_compose_opts_help | remove_options_in_option_help_msg --version --help --verbose | filter_docker_compose_help_message @@ -2663,6 +2666,7 @@ export DOCKER_HOST_NET DOCKER_HOST_IP services=() remainder_args=() compose_opts=() +compose_contents=() action_opts=() services_args=() pos_arg_ct=0 @@ -2725,6 +2729,11 @@ while read-0 arg; do export VERBOSE=true #compose_opts+=("--verbose" "--log-level" "DEBUG") ;; + --add-compose-content|-Y) + read-0 value + compose_contents+=("$value") + shift + ;; --dirs) echo "CACHEDIR: $CACHEDIR" echo "VARDIR: $VARDIR" @@ -2817,6 +2826,7 @@ while read-0 arg; do done < <(cla.normalize "$@") +export compose_contents [ "${services_args[*]}" ] && debug " ${DARKWHITE}Services:$NORMAL ${DARKYELLOW}${services_args[*]}$NORMAL" [ "${compose_opts[*]}" ] && debug " ${DARKWHITE}Main docker-compose opts:$NORMAL ${compose_opts[*]}" [ "${action_posargs[*]}" ] && debug " ${DARKWHITE}Main docker-compose pos args:$NORMAL ${action_posargs[*]}" diff --git a/test/injection b/test/injection new file mode 100755 index 0000000..36600fe --- /dev/null +++ b/test/injection @@ -0,0 +1,92 @@ +#!/usr/bin/env bash-shlib +# -*- mode: shell-script -*- + +include shunit + +depends sed grep git mkdir readlink + +export -f matches +export grep + +tmp=/tmp +tprog="../bin/compose" +tprog=$(readlink -f $tprog) + + +export PATH=".:$PATH" +short_tprog=$(basename "$tprog") + + +## +## Convenience function +## + +init_test() { + test_tmpdir=$(mktemp -d -t tmp.XXXXXXXXXX) + cd "$test_tmpdir" + export CACHEDIR="$test_tmpdir/.cache" + export VARDIR="$test_tmpdir/.var" + mkdir -p "$CACHEDIR" +} + + + +tear_test() { + rm -rf "$test_tmpdir" +} + + +## +## Tests +## + + +function test_injection { + + init_test + + export CHARM_STORE=$test_tmpdir + mkdir -p $test_tmpdir/{toto,titi} + cat < $test_tmpdir/toto/metadata.yml +docker-image: toto +EOF2 + + cat < $test_tmpdir/titi/metadata.yml +docker-image: titi +EOF2 + + cat < $test_tmpdir/compose.yml +web_site: + charm: toto +EOF2 + + export DISABLE_SYSTEM_CONFIG_FILE=true + + assert_list </dev/null) || exit 1 +out=\$(echo "\$out" | shyaml get-value services.web_site.image) || exit 1 +expected="titi" + +[ "\$out" == "\$expected" ] || { + echo -e "DIFF:\n\$(diff <(echo "\$out") <(echo "\$expected"))" + exit 1 +} + +EOF + + tear_test +} + + + +continue_on_error="0" testbench $*