#!/bin/bash

SERVICES=(user-service event-service ai-service content-service distribution-service participation-service analytics-service)

# Staging patches (2 replicas, increased resources)
for service in "${SERVICES[@]}"; do
  cat > ".github/kustomize/overlays/staging/${service}-patch.yaml" << YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${service}
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: ${service}
          resources:
            requests:
              cpu: "512m"
              memory: "512Mi"
            limits:
              cpu: "2048m"
              memory: "2048Mi"
YAML
done

# Prod patches (3 replicas, maximum resources)
for service in "${SERVICES[@]}"; do
  cat > ".github/kustomize/overlays/prod/${service}-patch.yaml" << YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${service}
spec:
  replicas: 3
  template:
    spec:
      containers:
        - name: ${service}
          resources:
            requests:
              cpu: "1024m"
              memory: "1024Mi"
            limits:
              cpu: "4096m"
              memory: "4096Mi"
YAML
done

echo "✅ Generated all patch files for staging and prod"
