#!/bin/bash
set -e
echo "=========================================="
echo "FINAL IMAGE FIX - Remove ALL and Re-import"
echo "=========================================="
echo ""
echo "Step 1: Removing ALL crossplane-provider-proxmox images..."
sudo ctr -n k8s.io images rm $(sudo ctr -n k8s.io images ls -q | grep crossplane-provider-proxmox || true) 2>/dev/null || echo "  (No images to remove)"
echo ""
echo "Step 2: Re-importing fresh image..."
sudo ctr -n k8s.io images import /tmp/crossplane-fresh-nuclear.tar
echo ""
echo "Step 3: Verifying import..."
sudo ctr -n k8s.io images ls | grep crossplane-provider-proxmox
echo ""
echo "✅ Image re-imported. Now delete and recreate the deployment:"
echo "   kubectl delete deployment crossplane-provider-proxmox -n crossplane-system"
echo "   kubectl apply -f /home/intlc/projects/Sankofa/crossplane-provider-proxmox/config/provider.yaml"
