Documentation
¶
Overview ¶
Package cluster groups all KSail cluster lifecycle Cobra commands under a single namespace.
This package contains commands for managing local Kubernetes cluster lifecycles, including init, create, delete, start, stop, list, info, connect, and switch operations.
Index ¶
- Variables
- func HandleInitRunE(cmd *cobra.Command, cfgManager *ksailconfigmanager.ConfigManager, ...) error
- func HandleListRunE(cmd *cobra.Command, providerFilter v1alpha1.Provider, deps ListDeps) error
- func HandleSwitchRunE(cmd *cobra.Command, clusterName string, deps SwitchDeps) error
- func InitFieldSelectors() []ksailconfigmanager.FieldSelector[v1alpha1.Cluster]
- func IsClusterContainer(containerName, clusterName string) bool
- func NewBackupCmd(_ *di.Runtime) *cobra.Command
- func NewClusterCmd(runtimeContainer *di.Runtime) *cobra.Command
- func NewConnectCmd(_ *di.Runtime) *cobra.Command
- func NewCreateCmd(runtimeContainer *di.Runtime) *cobra.Command
- func NewDeleteCmd(runtimeContainer *di.Runtime) *cobra.Command
- func NewInfoCmd(_ *di.Runtime) *cobra.Command
- func NewInitCmd(runtimeContainer *di.Runtime) *cobra.Command
- func NewListCmd(runtimeContainer *di.Runtime) *cobra.Command
- func NewRestoreCmd(_ *di.Runtime) *cobra.Command
- func NewStartCmd(_ any) *cobra.Command
- func NewStopCmd(_ any) *cobra.Command
- func NewSwitchCmd(_ *di.Runtime) *cobra.Command
- func NewUpdateCmd(runtimeContainer *di.Runtime) *cobra.Command
- func SetArgoCDInstallerFactoryForTests(factory func(*v1alpha1.Cluster) (installer.Installer, error)) func()
- func SetCSIInstallerFactoryForTests(factory func(*v1alpha1.Cluster) (installer.Installer, error)) func()
- func SetCertManagerInstallerFactoryForTests(factory func(*v1alpha1.Cluster) (installer.Installer, error)) func()
- func SetDockerClientInvokerForTests(invoker func(*cobra.Command, func(client.APIClient) error) error) func()
- func SetEnsureArgoCDResourcesForTests(fn func(context.Context, string, *v1alpha1.Cluster, string) error) func()
- func SetEnsureOCIArtifactForTests(...) func()
- func SetFluxInstallerFactoryForTests(factory func(*v1alpha1.Cluster) (installer.Installer, error)) func()
- func SetLocalRegistryServiceFactoryForTests(factory localregistry.ServiceFactoryFunc) func()
- func SetPolicyEngineInstallerFactoryForTests(factory func(*v1alpha1.Cluster) (installer.Installer, error)) func()
- func SetProvisionerFactoryForTests(factory clusterprovisioner.Factory) func()
- func SetSetupFluxInstanceForTests(fn func(context.Context, string, *v1alpha1.Cluster, string, string) error) func()
- func SetWaitForFluxReadyForTests(fn func(context.Context, string) error) func()
- type BackupMetadata
- type InitDeps
- type ListDeps
- type SwitchDeps
Constants ¶
This section is empty.
Variables ¶
var ErrAmbiguousCluster = errors.New("ambiguous cluster name")
ErrAmbiguousCluster is returned when multiple distribution contexts match the cluster name.
var ErrContextNotFound = errors.New("no matching context found for cluster")
ErrContextNotFound is returned when the specified cluster does not have a matching context in the kubeconfig.
var ErrInvalidCompressionLevel = errors.New(
"compression level out of range",
)
ErrInvalidCompressionLevel is returned when the compression level is outside the valid range.
var ErrInvalidResourcePolicy = errors.New(
"invalid existing-resource-policy: must be 'none' or 'update'",
)
ErrInvalidResourcePolicy is returned when an unsupported existing-resource-policy value is provided.
var ErrInvalidTarPath = errors.New("invalid tar entry path")
ErrInvalidTarPath is returned when a tar entry contains a path traversal attempt.
var ErrKubeconfigNotFound = errors.New(
"kubeconfig not found; ensure cluster is created and configured",
)
ErrKubeconfigNotFound is returned when no kubeconfig path can be resolved.
var ErrRestoreFailed = errors.New("resource restore failed")
ErrRestoreFailed is returned when one or more resources fail to restore.
var ErrSymlinkInArchive = errors.New(
"symbolic and hard links are not supported in backup archives",
)
ErrSymlinkInArchive is returned when a tar archive contains symbolic or hard links, which are not supported.
var ErrUnsupportedProvider = clustererr.ErrUnsupportedProvider
ErrUnsupportedProvider re-exports the shared error for backward compatibility.
Functions ¶
func HandleInitRunE ¶
func HandleInitRunE( cmd *cobra.Command, cfgManager *ksailconfigmanager.ConfigManager, deps InitDeps, ) error
HandleInitRunE handles the init command.
func HandleListRunE ¶
HandleListRunE handles the list command. Exported for testing purposes.
func HandleSwitchRunE ¶ added in v5.46.0
func HandleSwitchRunE( cmd *cobra.Command, clusterName string, deps SwitchDeps, ) error
HandleSwitchRunE handles the switch command. Exported for testing purposes.
func InitFieldSelectors ¶
func InitFieldSelectors() []ksailconfigmanager.FieldSelector[v1alpha1.Cluster]
InitFieldSelectors returns the field selectors used by the init command. Kept local (rather than separate file) to keep init-specific wiring cohesive.
func IsClusterContainer ¶ added in v5.24.0
IsClusterContainer checks if a container name belongs to the given cluster. Exported for testing.
func NewBackupCmd ¶ added in v5.40.0
NewBackupCmd creates the cluster backup command.
func NewClusterCmd ¶
NewClusterCmd creates the parent cluster command and wires lifecycle subcommands beneath it.
func NewConnectCmd ¶
NewConnectCmd creates the connect command for clusters.
func NewCreateCmd ¶
NewCreateCmd wires the cluster create command using the shared runtime container.
func NewDeleteCmd ¶
NewDeleteCmd creates and returns the delete command. Delete uses --name and --provider flags to determine the cluster to delete.
func NewInfoCmd ¶
NewInfoCmd creates the cluster info command. The command wraps kubectl cluster-info and appends TTL status when set.
func NewInitCmd ¶
NewInitCmd creates and returns the init command.
func NewListCmd ¶
NewListCmd creates the list command for clusters.
func NewRestoreCmd ¶ added in v5.40.0
NewRestoreCmd creates the cluster restore command.
func NewStartCmd ¶
NewStartCmd creates and returns the start command.
func NewStopCmd ¶
NewStopCmd creates and returns the stop command.
func NewSwitchCmd ¶ added in v5.46.0
NewSwitchCmd creates the switch command for clusters.
func NewUpdateCmd ¶ added in v5.30.0
NewUpdateCmd creates the cluster update command. The update command applies configuration changes to a running cluster. It supports in-place updates where possible and falls back to recreation when necessary.
func SetArgoCDInstallerFactoryForTests ¶
func SetArgoCDInstallerFactoryForTests( factory func(*v1alpha1.Cluster) (installer.Installer, error), ) func()
SetArgoCDInstallerFactoryForTests overrides the Argo CD installer factory.
func SetCSIInstallerFactoryForTests ¶
func SetCSIInstallerFactoryForTests( factory func(*v1alpha1.Cluster) (installer.Installer, error), ) func()
SetCSIInstallerFactoryForTests overrides the CSI installer factory.
func SetCertManagerInstallerFactoryForTests ¶
func SetCertManagerInstallerFactoryForTests( factory func(*v1alpha1.Cluster) (installer.Installer, error), ) func()
SetCertManagerInstallerFactoryForTests overrides the cert-manager installer factory.
func SetDockerClientInvokerForTests ¶
func SetDockerClientInvokerForTests( invoker func(*cobra.Command, func(client.APIClient) error) error, ) func()
SetDockerClientInvokerForTests overrides the Docker client invoker for testing.
func SetEnsureArgoCDResourcesForTests ¶
func SetEnsureArgoCDResourcesForTests( fn func(context.Context, string, *v1alpha1.Cluster, string) error, ) func()
SetEnsureArgoCDResourcesForTests overrides the Argo CD resource ensure function.
func SetEnsureOCIArtifactForTests ¶ added in v5.21.6
func SetEnsureOCIArtifactForTests( fn func(context.Context, *cobra.Command, *v1alpha1.Cluster, string, io.Writer) (bool, error), ) func()
SetEnsureOCIArtifactForTests overrides the OCI artifact ensure function.
func SetFluxInstallerFactoryForTests ¶ added in v5.15.0
func SetFluxInstallerFactoryForTests( factory func(*v1alpha1.Cluster) (installer.Installer, error), ) func()
SetFluxInstallerFactoryForTests overrides the Flux installer factory.
func SetLocalRegistryServiceFactoryForTests ¶ added in v5.15.0
func SetLocalRegistryServiceFactoryForTests(factory localregistry.ServiceFactoryFunc) func()
SetLocalRegistryServiceFactoryForTests overrides the local registry service factory for testing.
func SetPolicyEngineInstallerFactoryForTests ¶ added in v5.56.0
func SetPolicyEngineInstallerFactoryForTests( factory func(*v1alpha1.Cluster) (installer.Installer, error), ) func()
SetPolicyEngineInstallerFactoryForTests overrides the policy engine installer factory.
func SetProvisionerFactoryForTests ¶ added in v5.30.0
func SetProvisionerFactoryForTests(factory clusterprovisioner.Factory) func()
SetProvisionerFactoryForTests overrides the cluster provisioner factory for testing.
Types ¶
type BackupMetadata ¶ added in v5.40.0
type BackupMetadata struct {
Version string `json:"version"`
Timestamp time.Time `json:"timestamp"`
ClusterName string `json:"clusterName"`
Distribution string `json:"distribution"`
Provider string `json:"provider"`
KSailVersion string `json:"ksailVersion"`
ResourceCount int `json:"resourceCount"`
ResourceTypes []string `json:"resourceTypes"`
}
BackupMetadata contains metadata about a backup.
type ListDeps ¶
type ListDeps struct {
// DistributionFactoryCreator is an optional function that creates factories for distributions.
// If nil, real factories with empty configs are used.
// This is primarily for testing purposes.
DistributionFactoryCreator func(v1alpha1.Distribution) clusterprovisioner.Factory
// HetznerProvider is an optional Hetzner provider for listing Hetzner clusters.
// If nil, a real provider will be created if HCLOUD_TOKEN is set.
HetznerProvider *hetzner.Provider
// OmniProvider is an optional Omni provider for listing Omni clusters.
// If nil, a real provider will be created if OMNI_SERVICE_ACCOUNT_KEY is set.
OmniProvider *omni.Provider
}
ListDeps captures dependencies needed for the list command logic.
type SwitchDeps ¶ added in v5.46.0
type SwitchDeps struct {
// KubeconfigPath overrides the kubeconfig path resolution.
// If empty, the path is resolved from ksail.yaml or the default.
KubeconfigPath string
}
SwitchDeps captures injectable dependencies for the switch command.