package v1alpha1

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

// ProviderConfigSpec defines the desired state of ProviderConfig
type ProviderConfigSpec struct {
	// Credentials required to authenticate to Proxmox
	Credentials CredentialsSource `json:"credentials"`

	// Sites is a list of Proxmox sites/clusters
	Sites []ProxmoxSite `json:"sites,omitempty"`
}

// CredentialsSource specifies how credentials should be provided
type CredentialsSource struct {
	// Source is the source of credentials (Secret, InjectedIdentity, etc.)
	Source string `json:"source"`

	// SecretRef references a secret containing credentials
	SecretRef *SecretKeySelector `json:"secretRef,omitempty"`
}

// SecretKeySelector selects a key from a secret
type SecretKeySelector struct {
	// Name of the secret
	Name string `json:"name"`

	// Namespace of the secret
	Namespace string `json:"namespace"`

	// Key in the secret
	Key string `json:"key"`
}

// ProxmoxSite defines a Proxmox cluster/site
type ProxmoxSite struct {
	// Name is the site identifier
	Name string `json:"name"`

	// Endpoint is the Proxmox API endpoint
	Endpoint string `json:"endpoint"`

	// Node is the default node for this site
	Node string `json:"node,omitempty"`

	// InsecureSkipTLSVerify skips TLS verification
	InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty"`
}

// ProviderConfigStatus defines the observed state of ProviderConfig
type ProviderConfigStatus struct {
	// Conditions represent the latest available observations
	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// ProviderConfig is the Schema for the providerconfigs API
type ProviderConfig struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   ProviderConfigSpec   `json:"spec,omitempty"`
	Status ProviderConfigStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// ProviderConfigList contains a list of ProviderConfig
type ProviderConfigList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ProviderConfig `json:"items"`
}

func init() {
	SchemeBuilder.Register(&ProviderConfig{}, &ProviderConfigList{})
}

