Documentation
¶
Overview ¶
Package shared provides reusable helpers for command wiring.
This package contains shared utilities for command construction including configuration loading and kubeconfig path resolution.
Index ¶
- Variables
- func GetDefaultKubeconfigPath() string
- func GetKubeconfigPathFromConfig(cfg *v1alpha1.Cluster) (string, error)
- func GetKubeconfigPathSilently() string
- func HandleLifecycleRunE(cmd *cobra.Command, cfgManager *ksailconfigmanager.ConfigManager, ...) error
- func LoadConfig(cfgManager *ksailconfigmanager.ConfigManager, deps ConfigLoadDeps) error
- func NewConfigLoaderRunE(runtimeContainer *runtime.Runtime) func(*cobra.Command, []string) error
- func NewLifecycleCommandWrapper(runtimeContainer *runtime.Runtime, ...) func(*cobra.Command, []string) error
- func RunLifecycleWithConfig(cmd *cobra.Command, deps LifecycleDeps, config LifecycleConfig, ...) error
- func WithDockerClient(cmd *cobra.Command, operation func(client.APIClient) error) error
- func WithDockerClientInstance(cmd *cobra.Command, dockerClient client.APIClient, ...) error
- func WrapLifecycleHandler(runtimeContainer *runtime.Runtime, ...) func(*cobra.Command, []string) error
- type ConfigLoadDeps
- type LifecycleAction
- type LifecycleConfig
- type LifecycleDeps
Constants ¶
This section is empty.
Variables ¶
var ErrMissingClusterProvisionerDependency = errors.New("missing cluster provisioner dependency")
ErrMissingClusterProvisionerDependency indicates that a lifecycle command resolved a nil provisioner.
Functions ¶
func GetDefaultKubeconfigPath ¶
func GetDefaultKubeconfigPath() string
GetDefaultKubeconfigPath returns the default kubeconfig path.
func GetKubeconfigPathFromConfig ¶
GetKubeconfigPathFromConfig extracts and expands the kubeconfig path from a loaded cluster config. If the config doesn't specify a path, returns the default kubeconfig path.
func GetKubeconfigPathSilently ¶
func GetKubeconfigPathSilently() string
GetKubeconfigPathSilently tries to load config and get kubeconfig path without any output.
func HandleLifecycleRunE ¶
func HandleLifecycleRunE( cmd *cobra.Command, cfgManager *ksailconfigmanager.ConfigManager, deps LifecycleDeps, config LifecycleConfig, ) error
HandleLifecycleRunE orchestrates the standard lifecycle workflow including config loading and timing.
func LoadConfig ¶
func LoadConfig(cfgManager *ksailconfigmanager.ConfigManager, deps ConfigLoadDeps) error
LoadConfig loads the KSail configuration while tracking timing information.
func NewConfigLoaderRunE ¶
NewConfigLoaderRunE returns a cobra RunE that loads the KSail configuration using the runtime container.
func NewLifecycleCommandWrapper ¶
func NewLifecycleCommandWrapper( runtimeContainer *runtime.Runtime, cfgManager *ksailconfigmanager.ConfigManager, config LifecycleConfig, ) func(*cobra.Command, []string) error
NewLifecycleCommandWrapper creates a cobra RunE wrapper that resolves dependencies and calls HandleLifecycleRunE.
func RunLifecycleWithConfig ¶
func RunLifecycleWithConfig( cmd *cobra.Command, deps LifecycleDeps, config LifecycleConfig, clusterCfg *v1alpha1.Cluster, ) error
RunLifecycleWithConfig executes a lifecycle command using a pre-loaded cluster configuration.
func WithDockerClient ¶
WithDockerClient creates a Docker client, executes the given function, and cleans up. Returns an error if client creation fails or if the function returns an error. For testing, use WithDockerClientInstance with a mock client instead.
func WithDockerClientInstance ¶
func WithDockerClientInstance( cmd *cobra.Command, dockerClient client.APIClient, operation func(client.APIClient) error, ) error
WithDockerClientInstance executes the given function with a provided Docker client and handles cleanup. This is useful for testing with mock clients. The client will be closed after the operation completes.
func WrapLifecycleHandler ¶
func WrapLifecycleHandler( runtimeContainer *runtime.Runtime, cfgManager *ksailconfigmanager.ConfigManager, handler func(*cobra.Command, *ksailconfigmanager.ConfigManager, LifecycleDeps) error, ) func(*cobra.Command, []string) error
WrapLifecycleHandler resolves lifecycle dependencies from the runtime container before calling the provided handler.
Types ¶
type ConfigLoadDeps ¶
ConfigLoadDeps captures dependencies required for loading KSail configuration files.
type LifecycleAction ¶
type LifecycleAction func( ctx context.Context, provisioner clusterprovisioner.ClusterProvisioner, clusterName string, ) error
LifecycleAction represents a lifecycle operation executed against a cluster provisioner.
type LifecycleConfig ¶
type LifecycleConfig struct {
TitleEmoji string
TitleContent string
ActivityContent string
SuccessContent string
ErrorMessagePrefix string
Action LifecycleAction
}
LifecycleConfig describes the messaging and action behaviour for a lifecycle command.
type LifecycleDeps ¶
type LifecycleDeps struct {
Timer timer.Timer
Factory clusterprovisioner.Factory
}
LifecycleDeps groups the injectable collaborators required by lifecycle commands.