#!/usr/bin/env bash set -e ROOT_DOMAIN_NAME="infra-root" OWNER="platform-team" echo "Generating Backstage catalog files..." # # 1. Create root catalog-info.yaml # ROOT_FILE="catalog-info.yaml" if [[ -f "$ROOT_FILE" ]]; then echo "Root catalog-info.yaml already exists — skipping" else echo "Creating root catalog-info.yaml" cat > "$ROOT_FILE" <> "$ROOT_FILE" for d in "${TOP_LEVEL_DIRS[@]}"; do name=$(basename "$d") echo " - ./${name}/catalog-info.yaml" >> "$ROOT_FILE" done # # 2. Process each top-level directory as a System # for dir in "${TOP_LEVEL_DIRS[@]}"; do SYS_NAME=$(basename "$dir") SYS_FILE="${dir}/catalog-info.yaml" if [[ -f "$SYS_FILE" ]]; then echo "System file already exists for $SYS_NAME — skipping" else echo "Creating system catalog-info.yaml for $SYS_NAME" cat > "$SYS_FILE" <> "$SYS_FILE" done # # 3. Create component files in subdirectories # for s in "${SUBDIRS[@]}"; do SUB_NAME=$(basename "$s") COMPONENT_FILE="${s}/catalog-info.yaml" if [[ -f "$COMPONENT_FILE" ]]; then echo "Component file exists for $SYS_NAME/$SUB_NAME — skipping" else echo "Creating component file: $SYS_NAME/$SUB_NAME" cat > "$COMPONENT_FILE" <