This commit is contained in:
alessandro barucci
2026-08-09 17:03:02 +02:00
parent 5997a56cb3
commit 1a2cca2cd2
11 changed files with 1334 additions and 4 deletions

View File

@@ -5,24 +5,26 @@ set -euo pipefail
# env e' ignorato: endpoint viene sempre letto dalla chiave "endpoint".
ENVIRONMENT="${1:-dev}"
PROPERTIES_FILE="${2:-env/${ENVIRONMENT}/values.env}"
# Hardening per evitare errori con set -u in esecuzioni/sourcing anomali
: "${PROPERTIES_FILE:=env/${ENVIRONMENT}/values.env}"
if [[ -n "$ENVIRONMENT" ]]; then
echo "Ambiente richiesto: $ENVIRONMENT (chiave usata: endpoint)"
fi
if [[ ! -f "$PROPERTIES_FILE" ]]; then
echo "Warning: file non trovato: $PROPERTIES_FILE" >&2
if [[ ! -f "${PROPERTIES_FILE:-}" ]]; then
echo "Warning: file non trovato: ${PROPERTIES_FILE:-<non impostato>}" >&2
exit 0
fi
# Estrae endpoint ignorando commenti e spazi, supportando anche endpoint = valore
endpoint_raw="$({ grep -E '^[[:space:]]*endpoint[[:space:]]*=' "$PROPERTIES_FILE" | tail -n1 || true; } | sed -E 's/^[[:space:]]*endpoint[[:space:]]*=[[:space:]]*//')"
endpoint_raw="$({ grep -E '^[[:space:]]*endpoint[[:space:]]*=' "${PROPERTIES_FILE}" | tail -n1 || true; } | sed -E 's/^[[:space:]]*endpoint[[:space:]]*=[[:space:]]*//')"
# Rimuove eventuali virgolette e spazi ai bordi
endpoint="$(echo "$endpoint_raw" | sed -E 's/^[[:space:]"\x27]+//; s/[[:space:]"\x27]+$//')"
if [[ -z "$endpoint" ]]; then
echo "La chiave endpoint non e valorizzata in $PROPERTIES_FILE" >&2
echo "La chiave endpoint non e valorizzata in ${PROPERTIES_FILE:-<non impostato>}" >&2
exit 0
fi