From b34f521c51681528b57df632fc3cb0df91413dcc Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Tue, 20 Aug 2019 14:58:18 +0200 Subject: [PATCH] new: dev: factorize configuration files loading code --- bin/compose | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/compose b/bin/compose index 55d91d5..012740b 100755 --- a/bin/compose +++ b/bin/compose @@ -116,23 +116,13 @@ mk_docker_run_options() { ## if [ -z "$DISABLE_SYSTEM_CONFIG_FILE" ]; then - if [ -r /etc/default/charm ]; then - docker_run_opts+=("-v" "/etc/default/charm:/etc/default/charm:ro") - . /etc/default/charm - fi - ## XXXvlab: should provide YML config opportunities in possible parent dirs ? ## userdir ? and global /etc/compose.yml ? - for cfgfile in /etc/compose.conf /etc/compose.local.conf \ - /etc/default/compose /etc/compose/local.conf; do + for cfgfile in "${compose_config_files[@]}"; do [ -e "$cfgfile" ] || continue docker_run_opts+=("-v" "$cfgfile:$cfgfile:ro") . "$cfgfile" done - for cfgfile in /etc/default/datastore; do - [ -e "$cfgfile" ] || continue - docker_run_opts+=("-v" "$cfgfile:$cfgfile:ro") - done else docker_run_opts+=("-e" "DISABLE_SYSTEM_CONFIG_FILE=$DISABLE_SYSTEM_CONFIG_FILE") fi @@ -220,6 +210,16 @@ mk_docker_run_options() { run() { local os docker_run_opts + ## Order matters, files get to override vars + compose_config_files=( + /etc/default/charm + /etc/default/datastore + /etc/compose.conf + /etc/compose.local.conf + /etc/default/compose + /etc/compose/local.conf + ) + os=$(get_os) case "$os" in linux)