From cdcb310c936e23736e3bd72c8bcad12afc564916 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 12 Jan 2022 18:46:32 +0100 Subject: [PATCH] chg: dev: [odoo-tecnativa] refactor out and strengthen detection of running container Signed-off-by: Valentin Lab --- odoo-tecnativa/actions/drop | 16 ++++++---------- odoo-tecnativa/actions/load | 16 ++++++---------- odoo-tecnativa/actions/save | 17 ++++++----------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/odoo-tecnativa/actions/drop b/odoo-tecnativa/actions/drop index 28c802c..0927a1e 100755 --- a/odoo-tecnativa/actions/drop +++ b/odoo-tecnativa/actions/drop @@ -96,18 +96,14 @@ ADMIN_PASSWORD=$(echo "$service_def" | shyaml -q get-value options.admin-passwor fi } -containers="$(get_running_containers_for_service "$SERVICE_NAME")" - -if [ -z "$containers" ]; then - err "No containers running for service $DARKYELLOW$SERVICE_NAME$NORMAL." - die "Please ensure that $DARKYELLOW$SERVICE_NAME$NORMAL is running before using '$exname'." -fi +container_network_ip=$(get_healthy_container_ip_for_service "$SERVICE_NAME" 8069 4) || { + err "Please ensure that $DARKYELLOW$service$NORMAL is running before using '$exname'." + exit 1 +} -## XXXvlab: taking first container is probably not a good idea -container="$(echo "$containers" | head -n 1)" +container_ip=${container_network_ip##*:} +container_network=${container_network_ip%%:*} -## XXXvlab: taking first ip is probably not a good idea -read-0 container_network container_ip < <(get_container_network_ip "$container") DEFAULT_CURL_IMAGE=${DEFAULT_CURL_IMAGE:-docker.0k.io/curl} diff --git a/odoo-tecnativa/actions/load b/odoo-tecnativa/actions/load index ef6120a..f931be5 100755 --- a/odoo-tecnativa/actions/load +++ b/odoo-tecnativa/actions/load @@ -97,18 +97,14 @@ ADMIN_PASSWORD=$(echo "$service_def" | shyaml -q get-value options.admin-passwor fi } -containers="$(get_running_containers_for_service "$SERVICE_NAME")" - -if [ -z "$containers" ]; then - err "No containers running for service $DARKYELLOW$SERVICE_NAME$NORMAL." - die "Please ensure that $DARKYELLOW$SERVICE_NAME$NORMAL is running before using '$exname'." -fi +container_network_ip=$(get_healthy_container_ip_for_service "$SERVICE_NAME" 8069 4) || { + err "Please ensure that $DARKYELLOW$service$NORMAL is running before using '$exname'." + exit 1 +} -## XXXvlab: taking first container is probably not a good idea -container="$(echo "$containers" | head -n 1)" +container_ip=${container_network_ip##*:} +container_network=${container_network_ip%%:*} -## XXXvlab: taking first ip is probably not a good idea -read-0 container_network container_ip < <(get_container_network_ip "$container") DEFAULT_CURL_IMAGE=${DEFAULT_CURL_IMAGE:-docker.0k.io/curl} diff --git a/odoo-tecnativa/actions/save b/odoo-tecnativa/actions/save index 6d2cd24..1a312e5 100755 --- a/odoo-tecnativa/actions/save +++ b/odoo-tecnativa/actions/save @@ -96,18 +96,13 @@ ADMIN_PASSWORD=$(echo "$service_def" | shyaml -q get-value options.admin-passwor fi } -containers="$(get_running_containers_for_service "$SERVICE_NAME")" - -if [ -z "$containers" ]; then - err "No containers running for service $DARKYELLOW$SERVICE_NAME$NORMAL." - die "Please ensure that $DARKYELLOW$SERVICE_NAME$NORMAL is running before using '$exname'." -fi - -## XXXvlab: taking first container is probably not a good idea -container="$(echo "$containers" | head -n 1)" +container_network_ip=$(get_healthy_container_ip_for_service "$SERVICE_NAME" 8069 4) || { + err "Please ensure that $DARKYELLOW$service$NORMAL is running before using '$exname'." + exit 1 +} -## XXXvlab: taking first ip is probably not a good idea -read-0 container_network container_ip < <(get_container_network_ip "$container") +container_ip=${container_network_ip##*:} +container_network=${container_network_ip%%:*} DEFAULT_CURL_IMAGE=${DEFAULT_CURL_IMAGE:-docker.0k.io/curl}