#!/usr/bin/env bash # `make plan ENV=` — show what would be deployed for the given env. # # Merges manifests/ with overlays//overlay.toml and writes the resolved # service set to .orca-out//. Does NOT contact a cluster. # # Behavior in M1.1: the merge is a passthrough (overlays are placeholders). # A real merge that resolves per-env image tags and replica counts will land # alongside the first env-specific delta (M1.2 or later). set -euo pipefail ENV="${ENV:?usage: make plan ENV=}" case "$ENV" in dev|stage|prod) ;; *) echo "unknown env: $ENV" >&2; exit 2;; esac ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" OUT="$ROOT/.orca-out/$ENV" rm -rf "$OUT" mkdir -p "$OUT" OVERLAY="overlays/$ENV/overlay.toml" [ -f "$OVERLAY" ] || { echo "missing $OVERLAY" >&2; exit 1; } # Read include_dirs from overlay; fall back to all VMs (dev default). INCLUDE_DIRS=$(python3 - "$OVERLAY" <<'PY' import sys, tomllib data = tomllib.load(open(sys.argv[1], 'rb')) dirs = data.get('deploy', {}).get('include_dirs') if dirs is None: dirs = ['manifests/vm-edge', 'manifests/vm-control', 'manifests/vm-data', 'manifests/stage'] print('\n'.join(dirs)) PY ) echo "=== plan ENV=$ENV ===" echo "overlay: $OVERLAY" echo "include_dirs:" echo "$INCLUDE_DIRS" | sed 's/^/ /' echo count=0 while IFS= read -r dir; do [ -d "$dir" ] || continue for tml in "$dir"/*.toml; do [ -e "$tml" ] || continue rel="${tml#manifests/}" dest="$OUT/$rel" mkdir -p "$(dirname "$dest")" cp "$tml" "$dest" count=$((count+1)) done done <<< "$INCLUDE_DIRS" echo "→ wrote $count resolved manifests to .orca-out/$ENV/" echo "→ apply with: ORCA_API_URL= make apply ENV=$ENV"