From cb51c48c808a29a47856192f0c8b7f603f6ca171 Mon Sep 17 00:00:00 2001 From: mishaschwartz <4380924+mishaschwartz@users.noreply.github.com> Date: Tue, 15 Aug 2023 11:58:22 -0400 Subject: [PATCH] remove need to update docker compose (for now) --- birdhouse/pavics-compose.sh | 6 +++++- birdhouse/read-configs.include.sh | 2 +- tests/test_read_configs_include.py | 21 ++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/birdhouse/pavics-compose.sh b/birdhouse/pavics-compose.sh index 4f8a8517d..f527475e3 100755 --- a/birdhouse/pavics-compose.sh +++ b/birdhouse/pavics-compose.sh @@ -128,8 +128,12 @@ if [ x"$1" = x"up" ]; then echo "COMPOSE_CONF_LIST=" echo ${COMPOSE_CONF_LIST} | tr ' ' '\n' | grep -v '^-f' + cp "${COMPOSE_DIR}/docker-compose.yml" "${COMPOSE_FILE}" + # the PROXY_SECURE_PORT is a little trick to make the compose file invalid without the usage of this wrapper script - PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker compose --project-directory "${BUILD_DIR}" ${COMPOSE_CONF_LIST} config -o "${COMPOSE_FILE}" + PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker-compose ${COMPOSE_CONF_LIST} config > "${COMPOSE_FILE}.final" + + mv "${COMPOSE_FILE}.final" "${COMPOSE_FILE}" fi docker compose -f "${COMPOSE_FILE}" "$@" diff --git a/birdhouse/read-configs.include.sh b/birdhouse/read-configs.include.sh index 6184c0f82..89ebe443a 100644 --- a/birdhouse/read-configs.include.sh +++ b/birdhouse/read-configs.include.sh @@ -211,7 +211,7 @@ create_compose_conf_list() { [ -z "$BUILD_DIR" ] && return - COMPOSE_CONF_LIST="-f ${COMPOSE_DIR}/docker-compose.yml" + COMPOSE_CONF_LIST="-f ${BUILD_DIR}/docker-compose.yml" COMPONENT_OVERRIDES='' LOADED_COMPONENTS='' for adir in $ALL_CONF_DIRS; do diff --git a/tests/test_read_configs_include.py b/tests/test_read_configs_include.py index 1cfa0e218..4484c16a0 100644 --- a/tests/test_read_configs_include.py +++ b/tests/test_read_configs_include.py @@ -177,9 +177,9 @@ def test_delayed_eval_custom_value(self, read_config_include_file) -> None: class TestCreateComposeConfList: @staticmethod - def default_conf_list_order(tmp_build_dir, root_dir) -> list[str]: + def default_conf_list_order(tmp_build_dir) -> list[str]: return [ - f"{root_dir}/birdhouse/docker-compose.yml", + f"{tmp_build_dir}/docker-compose.yml", f"{tmp_build_dir}/proxy/docker-compose-extra.yml", f"{tmp_build_dir}/canarie-api/config/proxy/docker-compose-extra.yml", f"{tmp_build_dir}/geoserver/docker-compose-extra.yml", @@ -244,13 +244,13 @@ def run_func(self, include_file: str, local_env: dict, command_suffix: str = "") ) return proc - def test_all_conf_dirs_empty(self, read_config_include_file, tmp_build_dir, root_dir): + def test_all_conf_dirs_empty(self, read_config_include_file, tmp_build_dir): """Test that only the base compose file is used when ALL_CONF_DIRS is empty""" proc = self.run_func(read_config_include_file, {"BUILD_DIR": tmp_build_dir}, 'echo "$COMPOSE_CONF_LIST"') - assert split_and_strip(get_command_stdout(proc)) == [f"-f {root_dir}/birdhouse/docker-compose.yml"] + assert split_and_strip(get_command_stdout(proc)) == [f"-f {tmp_build_dir}/docker-compose.yml"] @pytest.mark.usefixtures("run_in_compose_dir") - def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir, root_dir): + def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir): """Test that COMPOSE_CONF_LIST is set correctly when there are no overrides""" proc = self.run_func( read_config_include_file, @@ -259,7 +259,7 @@ def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir, roo ) print(proc.stdout) # useful for debugging when assert fail assert split_and_strip(get_command_stdout(proc), split_on="-f") == [ - f"{root_dir}/birdhouse/docker-compose.yml", + f"{tmp_build_dir}/docker-compose.yml", f"{tmp_build_dir}/finch/docker-compose-extra.yml", f"{tmp_build_dir}/raven/docker-compose-extra.yml", ] @@ -277,7 +277,7 @@ def test_compose_in_order(self, read_config_include_file): assert out1 == out2[:1] + out2[:0:-1] @pytest.mark.usefixtures("run_in_compose_dir") - def test_compose_overrides(self, read_config_include_file, tmp_build_dir, root_dir): + def test_compose_overrides(self, read_config_include_file, tmp_build_dir): """Test that COMPOSE_CONF_LIST is set correctly when there are overrides""" proc = self.run_func( read_config_include_file, @@ -286,19 +286,18 @@ def test_compose_overrides(self, read_config_include_file, tmp_build_dir, root_d ) print(proc.stdout) # useful for debugging when assert fail assert split_and_strip(get_command_stdout(proc), split_on="-f") == [ - f"{root_dir}/birdhouse/docker-compose.yml", + f"{tmp_build_dir}/docker-compose.yml", f"{tmp_build_dir}/finch/docker-compose-extra.yml", f"{tmp_build_dir}/magpie/docker-compose-extra.yml", f"{tmp_build_dir}/finch/config/magpie/docker-compose-extra.yml", ] @pytest.mark.usefixtures("run_in_compose_dir") - def test_default_all_conf_dirs(self, read_config_include_file, tmp_build_dir, root_dir): + def test_default_all_conf_dirs(self, read_config_include_file, tmp_build_dir): proc = self.run_func( read_config_include_file, {"ALL_CONF_DIRS": " ".join(TestReadConfigs.default_all_conf_order), "BUILD_DIR": tmp_build_dir}, 'echo "$COMPOSE_CONF_LIST"', ) print(proc.stdout) # useful for debugging when assert fail - assert split_and_strip(get_command_stdout(proc), split_on="-f") == self.default_conf_list_order(tmp_build_dir, - root_dir) + assert split_and_strip(get_command_stdout(proc), split_on="-f") == self.default_conf_list_order(tmp_build_dir)