#!/usr/bin/env bash set -euo pipefail WIRE_VALUES="" MAIN_DOMAIN="" NGINX_VALUES="" NGINX_DOMAIN="" NAMESPACE="default" CHECK_NGINX=false CREATE_NGINX_VALUES=false MULTI_DOMAINS=() need() { command -v "$1" >/dev/null || { echo "ERROR: missing dependency: $1"; exit 2; }; } ok() { echo "OK: $*"; } fail() { echo "MISSING/WRONG: $*"; FAILED=1; } usage() { cat </dev/null 2>&1 } print_wire_snippet() { local d="$1" cat </dev/null 2>&1; then fail "remove cargohold.config.aws.s3DownloadEndpoint; use cargohold.config.aws.multiIngress instead" else ok "cargohold.config.aws.s3DownloadEndpoint absent" fi for d in "${MULTI_DOMAINS[@]}"; do echo echo "Checking multi-ingress domain: $d" domain_failed_before="$FAILED" yaml_has_list_value '.nginz.nginx_conf.additional_external_env_domains' "$d" "$WIRE_VALUES" \ && ok "nginz additional_external_env_domains contains $d" \ || fail "add $d to nginz.nginx_conf.additional_external_env_domains" yaml_has_list_value '.cannon.nginx_conf.additional_external_env_domains' "$d" "$WIRE_VALUES" \ && ok "cannon additional_external_env_domains contains $d" \ || fail "add $d to cannon.nginx_conf.additional_external_env_domains" if yq -e 'galley.config.settings.conversationCodeURI? != null' "$WIRE_VALUES" >/dev/null 2>&1; then fail "remove galley.config.settings.conversationCodeURI; use .galley.config.settings.multiIngress instead" else ok "galley.config.settings.conversationCodeURI absent" fi [[ "$(yaml_get ".galley.config.settings.multiIngress.\"$d\"" "$WIRE_VALUES")" == "https://account.${d}/conversation-join/" ]] \ && ok "galley.config.settings.multiIngress for $d" \ || fail "add galley.config.settings.multiIngress.\"$d\": https://account.${d}/conversation-join/" [[ "$(yaml_get ".cargohold.config.aws.multiIngress.\"nginz-https.${d}\"" "$WIRE_VALUES")" == "https://assets.${d}" ]] \ && ok "cargohold multiIngress for $d" \ || fail "add cargohold.config.aws.multiIngress.\"nginz-https.${d}\": https://assets.${d}" base=".nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints" [[ "$(yaml_get "$base.backendURL" "$WIRE_VALUES")" == "https://nginz-https.${d}" ]] \ && ok "nginz multi_ingress_deeplink $d backendURL" \ || fail "set nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints.backendURL" [[ "$(yaml_get "$base.backendWSURL" "$WIRE_VALUES")" == "https://nginz-ssl.${d}" ]] \ && ok "nginz multi_ingress_deeplink $d backendWSURL" \ || fail "set nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints.backendWSURL" [[ "$(yaml_get "$base.teamsURL" "$WIRE_VALUES")" == "https://teams.${d}" ]] \ && ok "nginz multi_ingress_deeplink $d teamsURL" \ || fail "set nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints.teamsURL" [[ "$(yaml_get "$base.accountsURL" "$WIRE_VALUES")" == "https://account.${d}" ]] \ && ok "nginz multi_ingress_deeplink $d accountsURL" \ || fail "set nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints.accountsURL" [[ "$(yaml_get "$base.websiteURL" "$WIRE_VALUES")" == "https://${d}" ]] \ && ok "nginz multi_ingress_deeplink $d websiteURL" \ || fail "set nginz.nginx_conf.multi_ingress_deeplink.\"$d\".endpoints.websiteURL" if [[ "$FAILED" -ne "$domain_failed_before" ]]; then print_wire_snippet "$d" fi done } slug() { echo "$1" | sed 's/\..*$//' | tr -cd '[:alnum:]-' | tr '[:upper:]' '[:lower:]' } check_main_nginx_exists() { need kubectl echo "Checking Kubernetes ingress for main domain: $MAIN_DOMAIN" if kubectl get ingress -A -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{" "}{range .spec.rules[*]}{.host}{" "}{end}{"\n"}{end}' \ | grep -F "$MAIN_DOMAIN" >/dev/null; then ok "main nginx-ingress-services ingress appears to exist for $MAIN_DOMAIN" else fail "main nginx-ingress-services ingress not found for $MAIN_DOMAIN" cat < "$file" <