#!/bin/bash
# Collect Manifest IDs after creation
# Run this after creating manifests in Azure Portal

set -euo pipefail

GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'

log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }

echo "Enter Manifest IDs (press Enter to skip optional ones):"
echo ""

read -p "Default Manifest ID: " DEFAULT_ID
read -p "Diplomatic Manifest ID (optional): " DIPLOMATIC_ID
read -p "Judicial Manifest ID (optional): " JUDICIAL_ID
read -p "Financial Manifest ID (optional): " FINANCIAL_ID

if [ -z "${DEFAULT_ID}" ]; then
    log_warning "Default Manifest ID is required"
    exit 1
fi

MANIFESTS="{"
MANIFESTS+="\"default\":\"${DEFAULT_ID}\""

[ -n "${DIPLOMATIC_ID}" ] && MANIFESTS+=",\"diplomatic\":\"${DIPLOMATIC_ID}\""
[ -n "${JUDICIAL_ID}" ] && MANIFESTS+=",\"judicial\":\"${JUDICIAL_ID}\""
[ -n "${FINANCIAL_ID}" ] && MANIFESTS+=",\"financial\":\"${FINANCIAL_ID}\""

MANIFESTS+="}"

echo ""
log_success "Manifest configuration generated:"
echo ""
echo "ENTRA_MANIFESTS='${MANIFESTS}'"
echo ""
log_info "Add this to your .env file or Kubernetes secrets"
echo ""
log_info "To update .env file automatically, run:"
echo "  echo \"ENTRA_MANIFESTS='${MANIFESTS}'\" >> .env"

