prole/tests/etc/test_prole_cfg_hyphenated_keys_normalized.sh
chrisfu bfa712273e Implement split-cluster host ownership and context-safe deploy wiring
- move Supabase k8s ingress defaults to env-indexed api/db hostnames and remove legacy host bleed-through

- enforce explicit APP/DB kubecontext role validation across cluster ops and init scripts

- align env/default derivation and extend tests for hostname rendering and context checks

Co-authored-by: Junie <junie@jetbrains.com>
2026-04-12 21:00:20 -07:00

65 lines
1.4 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
# Regression test: config keys containing hyphens must be normalized to
# shell-safe variable names instead of crashing with "invalid variable name".
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PROLE_HOME=$(cd "$SCRIPT_DIR/../.." && pwd)
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
BIN_DIR="$TMP_DIR/bin"
mkdir -p "$BIN_DIR"
cat >"$BIN_DIR/kubectl" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
chmod +x "$BIN_DIR/kubectl"
cat >"$BIN_DIR/kubectx" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
chmod +x "$BIN_DIR/kubectx"
cat >"$BIN_DIR/kubens" <<'EOF'
#!/usr/bin/env bash
exit 0
EOF
chmod +x "$BIN_DIR/kubens"
export PATH="$BIN_DIR:$PATH"
CONF_DIR="$TMP_DIR/conf"
mkdir -p "$CONF_DIR/service"
cat >"$CONF_DIR/service/prole.cfg" <<EOF
[Global]
DEPLOYMENT_MODE = local
NAMESPACE = test-ns
PROLE_HOME = $PROLE_HOME
PROLE_SERVICE = $TMP_DIR/service
dependencies_gke-gcloud-auth-plugin_install = 1
EOF
ln -snf "service/prole.cfg" "$CONF_DIR/prole.cfg"
export PROLE_CONF="$CONF_DIR"
export PROLE_HOME
export PROLE_SERVICE="$TMP_DIR/service"
# shellcheck disable=SC1090
source "$PROLE_HOME/etc/prole_cfg.sh"
expected="1"
actual="${dependencies_gke_gcloud_auth_plugin_install:-}"
if [[ "$actual" != "$expected" ]]; then
echo "FAILURE: expected normalized key dependencies_gke_gcloud_auth_plugin_install=$expected, got '${actual:-<unset>}'" >&2
exit 1
fi
echo "SUCCESS"