#!/bin/bash
set -euo pipefail

# =============================================================================
# Setup kubectl for the tbi-shared-mgmt cluster
# Called by the CircleCI deploy-to-kubernetes job
# =============================================================================

CLUSTER_NAME="${CLUSTER_NAME:-tbi-shared-mgmt}"
AWS_REGION="${AWS_REGION:-ca-central-1}"

echo "=== Setting up kubectl for ${CLUSTER_NAME} ==="

aws eks update-kubeconfig \
  --region "${AWS_REGION}" \
  --name "${CLUSTER_NAME}"

echo "Current context:"
kubectl config current-context

echo "Cluster info:"
kubectl cluster-info

echo "✓ kubectl configured for ${CLUSTER_NAME}"
