From bcfe94cd8413df43dd6da66bfa175ceba0c70708 Mon Sep 17 00:00:00 2001 From: Francis Charette Migneault Date: Fri, 26 Jan 2024 11:51:46 -0500 Subject: [PATCH] move discover_compose_dir to resolve COMPOSE_DIR and reuse it to source logging utilities --- birdhouse/scripts/read-configs.include.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/birdhouse/scripts/read-configs.include.sh b/birdhouse/scripts/read-configs.include.sh index 5c7d83c4f..b5580128f 100644 --- a/birdhouse/scripts/read-configs.include.sh +++ b/birdhouse/scripts/read-configs.include.sh @@ -23,21 +23,11 @@ # read_configs -THIS_FILE="$(readlink -f "$0" || realpath "$0")" -THIS_DIR="$(dirname "$THIS_FILE")" - -if [ -f "${THIS_DIR}/logging.include.sh" ]; then - . "${THIS_DIR}/logging.include.sh" -fi -if [ -f "${THIS_DIR}/scripts/logging.include.sh" ]; then - . "${THIS_DIR}/scripts/logging.include.sh" -fi - - # Derive COMPOSE_DIR from the most probable locations. # This is NOT meant to be exhaustive. # Assume the checkout is named "birdhouse-deploy", which might NOT be true. # Caller of this file can simply set COMPOSE_DIR itself, this is the safest way. +# WARNING: cannot use 'log' calls within this function until the following logging script gets resolved and sourced. discover_compose_dir() { if [ -z "$COMPOSE_DIR" ] || [ ! -e "$COMPOSE_DIR" ]; then if [ -f "./pavics-compose.sh" ]; then @@ -66,12 +56,18 @@ discover_compose_dir() { # Case of sub-subdir of sibling checkout at same level as birdhouse-deploy. COMPOSE_DIR="$(realpath "../../../birdhouse-deploy/birdhouse")" fi - log INFO "Resolved docker-compose directory: [${COMPOSE_DIR}]" export COMPOSE_DIR fi } +discover_compose_dir +if [ -f "${COMPOSE_DIR}/scripts/logging.include.sh" ]; then + . "${COMPOSE_DIR}/scripts/logging.include.sh" +fi +log INFO "Resolved docker-compose directory: [${COMPOSE_DIR}]" + + discover_env_local() { if [ -z "$BIRDHOUSE_LOCAL_ENV" ]; then BIRDHOUSE_LOCAL_ENV="$COMPOSE_DIR/env.local"