fix pipeline
This commit is contained in:
@@ -29,18 +29,18 @@ if [[ -z "$HOSTNAME_VAL" || -z "$NAME_VAL" || -z "$SECRET_NAME" ]]; then
|
||||
fi
|
||||
|
||||
# Controlla idempotenza: verifica se il listener esiste già per nome o hostname
|
||||
EXISTING=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
|
||||
-o jsonpath='{.spec.listeners[*].name}')
|
||||
EXISTING_NAME=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
|
||||
-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."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
EXISTING_HOSTS=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
|
||||
-o jsonpath='{.spec.listeners[*].hostname}')
|
||||
EXISTING_HOST=$(kubectl get gateway "$GATEWAY_NAME" -n "$GATEWAY_NS" \
|
||||
-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."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -4,19 +4,19 @@ set -euo pipefail
|
||||
# Uso: ./addlistener.sh [env] [properties_file]
|
||||
# env e' ignorato: endpoint viene sempre letto dalla chiave "endpoint".
|
||||
ENVIRONMENT="${1:-dev}"
|
||||
PROPERTIES_FILE="${2:-env/${ENVIRONMENT}/values.env}"
|
||||
ENV_DIR="env/${ENVIRONMENT}"
|
||||
|
||||
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 [[ ! -d "$ENV_DIR" ]]; then
|
||||
echo "Warning: directory non trovata: $ENV_DIR" >&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:]]*//')"
|
||||
# Estrae endpoint da qualsiasi file .env nella directory dell'ambiente
|
||||
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
|
||||
endpoint="$(echo "$endpoint_raw" | sed -E 's/^[[:space:]"\x27]+//; s/[[:space:]"\x27]+$//')"
|
||||
|
||||
Reference in New Issue
Block a user