#!/bin/bash

echo "Fixing webrtc ArgoCD applications..."

# Set kubeconfig to staging
export KUBECONFIG=/Users/seth/workspace/video-iac/terraform/stg-kubeconfig.yaml

echo "Current ArgoCD applications:"
kubectl get applications -n argocd | grep webrtc

echo "Deleting webrtc-local if it exists..."
kubectl delete application webrtc-be-local -n argocd --ignore-not-found=true

echo "Deleting webrtc-be if it exists..."
kubectl delete application webrtc-be -n argocd --ignore-not-found=true

echo "Recreating applications..."
kubectl apply -f k8s/argocd/overlays/staging/applications.yaml

echo "Waiting for applications to be created..."
sleep 10

echo "Checking application status..."
kubectl get applications -n argocd | grep webrtc

echo "Done! Check ArgoCD UI to verify webrtc-be is syncing correctly."

