Documentation
¶
Overview ¶
Package k3d provides configuration management for K3d clusters.
This package contains the core Manager implementation for loading K3d cluster configurations from files, with support for environment variable overrides and Viper-based configuration management.
Index ¶
- Constants
- Variables
- func NewK3dSimpleConfig(name, apiVersion, kind string) *v1alpha5.SimpleConfig
- func ParseRegistryConfig(raw string) map[string][]string
- func ResolveClusterName(clusterCfg *v1alpha1.Cluster, k3dConfig *v1alpha5.SimpleConfig) string
- func ResolveNetworkName(clusterName string) string
- type ConfigManager
Constants ¶
const DefaultClusterName = "k3d-default"
DefaultClusterName is the default K3d cluster name when none is specified. This matches K3d's internal default naming convention.
Variables ¶
var DefaultK3sImage = k3sImage()
DefaultK3sImage is the default K3s container image. This value is read from the Dockerfile in this package which is updated by Dependabot.
Functions ¶
func NewK3dSimpleConfig ¶
func NewK3dSimpleConfig(name, apiVersion, kind string) *v1alpha5.SimpleConfig
NewK3dSimpleConfig creates a new v1alpha5.SimpleConfig with the specified name and TypeMeta. This function provides a canonical way to create K3d clusters with proper field initialization. Use empty string for name to create a cluster without a specific name.
func ParseRegistryConfig ¶
ParseRegistryConfig parses K3d registry mirror configuration from raw YAML string. Returns a map of host to endpoints, filtering out empty entries. Intentionally returns an empty map (instead of an error) for invalid YAML to support graceful degradation when registry configuration is malformed or missing.
func ResolveClusterName ¶
func ResolveClusterName( clusterCfg *v1alpha1.Cluster, k3dConfig *v1alpha5.SimpleConfig, ) string
ResolveClusterName returns the effective cluster name from K3d config or cluster config. Priority: k3dConfig.Name > clusterCfg.Spec.Cluster.Connection.Context > DefaultClusterName. Returns DefaultClusterName if both configs are nil or have empty names.
func ResolveNetworkName ¶
ResolveNetworkName returns the Docker network name for a K3d cluster. K3d uses "k3d-<clustername>" as the network naming convention.
Types ¶
type ConfigManager ¶
type ConfigManager struct {
// contains filtered or unexported fields
}
ConfigManager implements configuration management for K3d v1alpha5.SimpleConfig configurations. It provides file-based configuration loading without Viper dependency.
func NewConfigManager ¶
func NewConfigManager(configPath string) *ConfigManager
NewConfigManager creates a new configuration manager for K3d cluster configurations. configPath specifies the path to the K3d configuration file to load.
func (*ConfigManager) Load ¶
func (m *ConfigManager) Load(_ configmanager.LoadOptions) (*v1alpha5.SimpleConfig, error)
Load loads the K3d configuration from the specified file. Returns the loaded config, either freshly loaded or previously cached. If the file doesn't exist, returns a default K3d cluster configuration. Validates the configuration after loading and returns an error if validation fails. The opts parameter is accepted for interface compliance but not currently used.