fix pipeline

This commit is contained in:
alessandro
2026-07-30 09:56:19 +02:00
parent c7648b913b
commit c431fc36c5
2 changed files with 11 additions and 11 deletions

View File

@@ -29,18 +29,18 @@ if [[ -z "$HOSTNAME_VAL" || -z "$NAME_VAL" || -z "$SECRET_NAME" ]]; then
fi fi
# Controlla idempotenza: verifica se il listener esiste già per nome o hostname # Controlla idempotenza: verifica se il listener esiste già per nome o hostname
EXISTING=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \ EXISTING_NAME=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
-o jsonpath='{.spec.listeners[*].name}') -o jsonpath='{.spec.listeners[?(@.name=="'"${NAME_VAL}"'")].name}')
if echo "$EXISTING" | grep -qw "$NAME_VAL"; then if [[ -n "$EXISTING_NAME" ]]; then
echo "Attenzione: listener con name '${NAME_VAL}' già presente. Nessuna modifica." echo "Attenzione: listener con name '${NAME_VAL}' già presente. Nessuna modifica."
exit 0 exit 0
fi fi
EXISTING_HOSTS=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \ EXISTING_HOST=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
-o jsonpath='{.spec.listeners[*].hostname}') -o jsonpath='{.spec.listeners[?(@.hostname=="'"${HOSTNAME_VAL}"'")].hostname}')
if echo "$EXISTING_HOSTS" | grep -qw "$HOSTNAME_VAL"; then if [[ -n "$EXISTING_HOST" ]]; then
echo "Attenzione: listener con hostname '${HOSTNAME_VAL}' già presente. Nessuna modifica." echo "Attenzione: listener con hostname '${HOSTNAME_VAL}' già presente. Nessuna modifica."
exit 0 exit 0
fi fi

View File

@@ -4,19 +4,19 @@ set -euo pipefail
# Uso: ./addlistener.sh [env] [properties_file] # Uso: ./addlistener.sh [env] [properties_file]
# env e' ignorato: endpoint viene sempre letto dalla chiave "endpoint". # env e' ignorato: endpoint viene sempre letto dalla chiave "endpoint".
ENVIRONMENT="${1:-dev}" ENVIRONMENT="${1:-dev}"
PROPERTIES_FILE="${2:-env/${ENVIRONMENT}/values.env}" ENV_DIR="env/${ENVIRONMENT}"
if [[ -n "$ENVIRONMENT" ]]; then if [[ -n "$ENVIRONMENT" ]]; then
echo "Ambiente richiesto: $ENVIRONMENT (chiave usata: endpoint)" echo "Ambiente richiesto: $ENVIRONMENT (chiave usata: endpoint)"
fi fi
if [[ ! -f "$PROPERTIES_FILE" ]]; then if [[ ! -d "$ENV_DIR" ]]; then
echo "Warning: file non trovato: $PROPERTIES_FILE" >&2 echo "Warning: directory non trovata: $ENV_DIR" >&2
exit 0 exit 0
fi fi
# Estrae endpoint ignorando commenti e spazi, supportando anche endpoint = valore # Estrae endpoint da qualsiasi file .env nella directory dell'ambiente
endpoint_raw="$({ grep -E '^[[:space:]]*endpoint[[:space:]]*=' "$PROPERTIES_FILE" | tail -n1 || true; } | sed -E 's/^[[:space:]]*endpoint[[:space:]]*=[[:space:]]*//')" endpoint_raw="$({ grep -r '^[[:space:]]*endpoint[[:space:]]*=' "$ENV_DIR" 2>/dev/null | head -n1 || true; } | sed -E 's/^[^:]*:[[:space:]]*endpoint[[:space:]]*=[[:space:]]*//')"
# Rimuove eventuali virgolette e spazi ai bordi # Rimuove eventuali virgolette e spazi ai bordi
endpoint="$(echo "$endpoint_raw" | sed -E 's/^[[:space:]"\x27]+//; s/[[:space:]"\x27]+$//')" endpoint="$(echo "$endpoint_raw" | sed -E 's/^[[:space:]"\x27]+//; s/[[:space:]"\x27]+$//')"