localregistry

package
v5.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package localregistry provides local registry lifecycle operations for cluster commands. It handles provisioning, connecting, and cleaning up local Docker registries.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilRegistryContext = errors.New("registry stage context is nil")
	ErrUnsupportedStage   = errors.New("unsupported local registry stage")
)

Errors for local registry operations.

Functions

func Cleanup

func Cleanup(
	cmd *cobra.Command,
	cfgManager *ksailconfigmanager.ConfigManager,
	clusterCfg *v1alpha1.Cluster,
	deps lifecycle.Deps,
	deleteVolumes bool,
	localDeps Dependencies,
) error

Cleanup cleans up the local registry during cluster deletion. This function checks if the local registry container exists and removes it if present, regardless of the config setting. This ensures orphaned containers are cleaned up even when the config file is missing or has default values.

func CleanupStageInfo

func CleanupStageInfo() setup.StageInfo

CleanupStageInfo returns the stage info for cleanup.

func ConnectStageInfo

func ConnectStageInfo() setup.StageInfo

ConnectStageInfo returns the stage info for connecting.

func ExecuteStage

func ExecuteStage(
	cmd *cobra.Command,
	ctx *Context,
	deps lifecycle.Deps,
	stage StageType,
	firstActivityShown *bool,
	localDeps Dependencies,
) error

ExecuteStage executes the specified local registry stage.

func ProvisionStageInfo

func ProvisionStageInfo() setup.StageInfo

ProvisionStageInfo returns the stage info for provisioning.

func WaitForK3dLocalRegistryReady

func WaitForK3dLocalRegistryReady(
	cmd *cobra.Command,
	clusterCfg *v1alpha1.Cluster,
	k3dConfig *k3dv1alpha5.SimpleConfig,
	dockerInvoker func(*cobra.Command, func(client.APIClient) error) error,
) error

WaitForK3dLocalRegistryReady waits for the K3d-managed local registry to be ready. This should be called after K3d cluster creation when local registry is enabled, to ensure the registry is accepting connections before installing Flux or other components that depend on it.

For K3d, the local registry is created during cluster creation via Registries.Create, so we need to wait for it to be ready after the cluster is created. For Kind and Talos, this is a no-op since they use KSail-managed registries which are created and waited for before cluster creation.

Types

type Context

type Context struct {
	ClusterCfg  *v1alpha1.Cluster
	KindConfig  *kindv1alpha4.Cluster
	K3dConfig   *k3dv1alpha5.SimpleConfig
	TalosConfig *talosconfigmanager.Configs
}

Context holds cluster configuration for local registry operations.

func NewContextFromConfigManager

func NewContextFromConfigManager(cfgManager *ksailconfigmanager.ConfigManager) *Context

NewContextFromConfigManager creates a Context from a config manager.

type Dependencies

type Dependencies struct {
	ServiceFactory func(cfg registry.Config) (registry.Service, error)
	DockerInvoker  func(*cobra.Command, func(client.APIClient) error) error
}

Dependencies holds injectable dependencies for local registry operations.

func DefaultDependencies

func DefaultDependencies() Dependencies

DefaultDependencies returns the default production dependencies.

func NewDependencies

func NewDependencies(opts ...Option) Dependencies

NewDependencies creates dependencies with optional overrides.

type Option

type Option func(*Dependencies)

Option configures local registry dependencies.

func WithDockerInvoker

func WithDockerInvoker(invoker func(*cobra.Command, func(client.APIClient) error) error) Option

WithDockerInvoker sets a custom Docker client invoker.

func WithServiceFactory

func WithServiceFactory(factory func(cfg registry.Config) (registry.Service, error)) Option

WithServiceFactory sets a custom service factory.

type StageType

type StageType int

StageType represents the type of local registry stage operation.

const (
	// StageProvision creates the local registry container.
	StageProvision StageType = iota
	// StageConnect attaches the local registry to the cluster network.
	StageConnect
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL