Skip to content

Commit

Permalink
remove need to update docker compose (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishaschwartz committed Aug 15, 2023
1 parent e08a4f5 commit cb51c48
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
6 changes: 5 additions & 1 deletion birdhouse/pavics-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" "$@"
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/read-configs.include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions tests/test_read_configs_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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",
]
Expand All @@ -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,
Expand All @@ -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)

0 comments on commit cb51c48

Please sign in to comment.