workspace-v1/control-plane/devtools/scripts/validation/validate-domains.sh
Adrian Flores Cortes 967ab360bb Initial commit: Workspace v1 with 3-layer architecture
Structure:
- control-plane/: Registries, SIMCO directives, CI/CD templates
- projects/: Gamilit, ERP-Suite, Trading-Platform, Betting-Analytics
- shared/: Libs catalog, knowledge-base

Key features:
- Centralized port, domain, database, and service registries
- 23 SIMCO directives + 6 fundamental principles
- NEXUS agent profiles with delegation rules
- Validation scripts for workspace integrity
- Dockerfiles for all services
- Path aliases for quick reference

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 00:35:19 -06:00

102 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# ==============================================================================
# VALIDATE DOMAINS - Control Plane
# ==============================================================================
# Proposito: Validar que dominios en service descriptors coincidan con registry
# Mantenido por: DevOps-Agent
# ==============================================================================
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONTROL_PLANE="$(cd "$SCRIPT_DIR/../../.." && pwd)"
WORKSPACE="$(cd "$CONTROL_PLANE/.." && pwd)"
DOMAINS_REGISTRY="$CONTROL_PLANE/registries/domains.registry.yml"
# Colores
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
echo "=============================================="
echo " VALIDACION DE DOMINIOS"
echo "=============================================="
echo ""
# Verificar que existe domains.registry.yml
if [ ! -f "$DOMAINS_REGISTRY" ]; then
echo -e "${RED}[ERROR]${NC} No existe domains.registry.yml"
exit 1
fi
echo -e "${GREEN}[OK]${NC} domains.registry.yml encontrado"
echo ""
# Verificar YAML valido
if command -v python3 &> /dev/null; then
if python3 -c "import yaml; yaml.safe_load(open('$DOMAINS_REGISTRY'))" 2>/dev/null; then
echo -e "${GREEN}[OK]${NC} YAML valido"
else
echo -e "${RED}[ERROR]${NC} domains.registry.yml no es YAML valido"
exit 1
fi
else
echo -e "${YELLOW}[WARN]${NC} python3 no disponible, saltando validacion YAML"
fi
# Contar proyectos con dominios definidos
echo ""
echo "--- Proyectos con dominios ---"
PROJECTS=$(grep -E "^ [a-z_]+:" "$DOMAINS_REGISTRY" | grep -v "local:" | grep -v "development:" | grep -v "staging:" | grep -v "production:" | grep -v "api:" | grep -v "web:" | grep -v "admin:" | head -20 || true)
if [ -n "$PROJECTS" ]; then
echo "$PROJECTS" | while read -r line; do
PROJECT=$(echo "$line" | sed 's/://g' | xargs)
if [ -n "$PROJECT" ] && [ "$PROJECT" != "environments" ]; then
echo -e " ${GREEN}*${NC} $PROJECT"
fi
done
fi
# Verificar service descriptors referencian dominios validos
echo ""
echo "--- Validando Service Descriptors ---"
ERRORS=0
WARNINGS=0
find "$WORKSPACE/projects" -name "service.descriptor.yml" 2>/dev/null | while read -r descriptor; do
REL_PATH=$(echo "$descriptor" | sed "s|$WORKSPACE/||")
# Verificar que tiene domain definido
if grep -q "domain:" "$descriptor" 2>/dev/null; then
DOMAIN=$(grep "domain:" "$descriptor" | head -1 | awk '{print $2}' | tr -d '"')
# Verificar que el dominio esta en el registry
if grep -q "$DOMAIN" "$DOMAINS_REGISTRY" 2>/dev/null; then
echo -e " ${GREEN}[OK]${NC} $REL_PATH -> $DOMAIN"
else
echo -e " ${YELLOW}[WARN]${NC} $REL_PATH -> $DOMAIN (no en registry)"
((WARNINGS++)) || true
fi
else
echo -e " ${YELLOW}[INFO]${NC} $REL_PATH (sin domain definido)"
fi
done
echo ""
echo "=============================================="
if [ $ERRORS -gt 0 ]; then
echo -e "${RED}VALIDACION FALLIDA${NC} - $ERRORS errores encontrados"
exit 1
else
echo -e "${GREEN}VALIDACION EXITOSA${NC}"
if [ $WARNINGS -gt 0 ]; then
echo -e "${YELLOW}$WARNINGS advertencias${NC}"
fi
exit 0
fi