package v1alpha1

import (
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type ClusterSpec struct {
	InfraRef          string              `json:"infraRef"`
	KubernetesVersion string              `json:"kubernetesVersion"`
	ControlPlaneHA    bool                `json:"controlPlaneHA"`
	WorkerPools       []WorkerPoolRequest `json:"workerPools"`
}

type WorkerPoolRequest struct {
	Name     string `json:"name"`
	Quantity int    `json:"quantity"`
	CpuCores int    `json:"cpuCores"`
	MemoryGB int    `json:"memoryGb"`
	DiskGB   int    `json:"diskGb"`
}

// [NEW] Struct to track the Harvester Identity
type HarvesterAccountStatus struct {
	// The ServiceAccount created on Harvester (e.g. "prov-test-cluster-01")
	ServiceAccountName string `json:"serviceAccountName,omitempty"`
	// The Secret created in this namespace (e.g. "harvesterconfig-test-cluster-01")
	SecretRef string `json:"secretRef,omitempty"`
	// Expiry for future rotation logic
	TokenExpiresAt *metav1.Time `json:"tokenExpiresAt,omitempty"`
}

type ClusterStatus struct {
	Ready bool `json:"ready"`
	// +optional
	GeneratedAccount *HarvesterAccountStatus `json:"generatedAccount,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
type Cluster struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ClusterSpec   `json:"spec,omitempty"`
	Status            ClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true
type ClusterList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Cluster `json:"items"`
}

func init() {
	SchemeBuilder.Register(&Cluster{}, &ClusterList{})
}
