output "cluster_name" {
  description = "GKE cluster name."
  value       = google_container_cluster.main.name
}

output "cluster_id" {
  description = "Fully-qualified GKE cluster id (`projects/<id>/locations/<region>/clusters/<name>`)."
  value       = google_container_cluster.main.id
}

output "cluster_endpoint" {
  description = "GKE control-plane endpoint (HTTPS host)."
  value       = google_container_cluster.main.endpoint
}

output "cluster_certificate_authority_data" {
  description = "Base64-encoded cluster CA cert."
  value       = google_container_cluster.main.master_auth[0].cluster_ca_certificate
  sensitive   = true
}

output "workload_identity_pool" {
  description = "Workload Identity pool (`<project>.svc.id.goog`). Bind GCP SAs to KSAs via this."
  value       = "${var.project_id}.svc.id.goog"
}

output "project_id" {
  description = "GCP project id the cluster lives in."
  value       = var.project_id
}

output "project_number" {
  description = "GCP project number (useful in Workload Identity subjects)."
  value       = data.google_project.main.number
}

output "vpc_id" {
  description = "Dedicated VPC the cluster runs in."
  value       = google_compute_network.main.id
}

output "subnet_id" {
  description = "Subnet hosting the cluster."
  value       = google_compute_subnetwork.main.id
}

output "kubeconfig_path" {
  description = "Path to the rendered kubeconfig (relative to the working dir)."
  value       = local_sensitive_file.kubeconfig.filename
}

output "region" {
  description = "GCP region the cluster lives in."
  value       = var.region
}

# The Tier-3 service plane reads this to construct its `ServiceTarget(kubernetes)`.
output "service_target" {
  description = "Tier-2 → Tier-3 hand-off shape. The CLI projects this into ~/.aries/cluster/<name>/cluster.yaml."
  value = {
    kind          = "kubernetes"
    cloud         = "gcp"
    cluster_name  = google_container_cluster.main.name
    region        = var.region
    namespace     = "aries-datalake"
    ingress_class = "nginx"
    storage_class = "standard-rwo"
    kubeconfig    = local_sensitive_file.kubeconfig.filename
  }
}
