Browse Source

fix: dev: prevent duplication of network parameters

Previously, ``_set_db_params`` would be called several times and
parameters would then be concatenated. We didn't want
``_set_db_params`` to overwrite and start from scratch to let
possibility for customization before and after the call.

Here ``set_db_params`` will set a global variable to detect if it was
already launched prior to running content of ``_set_db_params``.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
master
Valentin Lab 4 years ago
parent
commit
32aaf2e0ea
  1. 17
      bin/compose-core

17
bin/compose-core

@ -696,6 +696,15 @@ are_files_locked_in_dir() {
export -f are_files_locked_in_dir
set_db_params() {
local docker_ip="$1" docker_network="$2"
if [ -z "$DB_PARAMS_LOADED" ]; then
DB_PARAMS_LOADED=1
_set_db_params "$docker_ip" "$docker_network"
fi
}
export -f set_db_params
export _PID="$$"
ensure_db_docker_running () {
local _STATE_FILE
@ -706,7 +715,7 @@ ensure_db_docker_running () {
IFS=: read DOCKER_NETWORK DOCKER_IP <<<"$(cat "$_STATE_FILE")"
debug "Re-using previous docker/connection '$DOCKER_IP'."
_set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
return 0
fi
@ -753,7 +762,7 @@ ensure_db_docker_running () {
docker pull "$DOCKER_BASE_IMAGE"
fi
_set_server_db_params
_set_server_db_params || return 1
debug docker network create "$_DB_NAME"
if ! network_id=$(docker network create "$_DB_NAME"); then
err "'docker network create $_DB_NAME' failed !"
@ -788,7 +797,7 @@ ensure_db_docker_running () {
echo "$docker_ip" > "$_STATE_FILE"
debug "written '$_STATE_FILE'"
rm "$state_tmpdir/${_DB_NAME}.working"
_set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
return 0
else
errlvl="$?"
@ -923,7 +932,7 @@ wait_for_docker_ip() {
err "internal 'wait_docker_ip' did not return a valid IP. Returned IP is '$DOCKER_IP'."
return 1
fi
_set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
set_db_params "$DOCKER_IP" "$DOCKER_NETWORK"
while read-0 port; do
IFS="/" read port type <<<"$port"
[ "$type" == "tcp" ] || continue

Loading…
Cancel
Save