Documentation
¶
Index ¶
- Variables
- type BaseConfigHandler
- func (c *BaseConfigHandler) Clean() error
- func (c *BaseConfigHandler) GetConfigRoot() (string, error)
- func (c *BaseConfigHandler) GetContext() string
- func (c *BaseConfigHandler) Initialize() error
- func (c *BaseConfigHandler) IsLoaded() bool
- func (c *BaseConfigHandler) SetContext(context string) error
- func (c *BaseConfigHandler) SetSecretsProvider(provider secrets.SecretsProvider)
- type ConfigHandler
- type MockConfigHandler
- func (m *MockConfigHandler) Clean() error
- func (m *MockConfigHandler) Get(key string) interface{}
- func (m *MockConfigHandler) GetBool(key string, defaultValue ...bool) bool
- func (m *MockConfigHandler) GetConfig() *v1alpha1.Context
- func (m *MockConfigHandler) GetConfigRoot() (string, error)
- func (m *MockConfigHandler) GetContext() string
- func (m *MockConfigHandler) GetInt(key string, defaultValue ...int) int
- func (m *MockConfigHandler) GetString(key string, defaultValue ...string) string
- func (m *MockConfigHandler) GetStringMap(key string, defaultValue ...map[string]string) map[string]string
- func (m *MockConfigHandler) GetStringSlice(key string, defaultValue ...[]string) []string
- func (m *MockConfigHandler) Initialize() error
- func (m *MockConfigHandler) IsLoaded() bool
- func (m *MockConfigHandler) LoadConfig(path string) error
- func (m *MockConfigHandler) SaveConfig(path string) error
- func (m *MockConfigHandler) Set(key string, value interface{}) error
- func (m *MockConfigHandler) SetContext(context string) error
- func (m *MockConfigHandler) SetContextValue(key string, value interface{}) error
- func (m *MockConfigHandler) SetDefault(context v1alpha1.Context) error
- func (m *MockConfigHandler) SetSecretsProvider(provider secrets.SecretsProvider)
- type YamlConfigHandler
- func (y *YamlConfigHandler) Get(path string) interface{}
- func (y *YamlConfigHandler) GetBool(key string, defaultValue ...bool) bool
- func (y *YamlConfigHandler) GetConfig() *v1alpha1.Context
- func (y *YamlConfigHandler) GetInt(key string, defaultValue ...int) int
- func (y *YamlConfigHandler) GetString(key string, defaultValue ...string) string
- func (y *YamlConfigHandler) GetStringMap(key string, defaultValue ...map[string]string) map[string]string
- func (y *YamlConfigHandler) GetStringSlice(key string, defaultValue ...[]string) []string
- func (y *YamlConfigHandler) LoadConfig(path string) error
- func (y *YamlConfigHandler) SaveConfig(path string) error
- func (y *YamlConfigHandler) Set(path string, value interface{}) error
- func (y *YamlConfigHandler) SetContextValue(path string, value interface{}) error
- func (y *YamlConfigHandler) SetDefault(context v1alpha1.Context) error
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = v1alpha1.Context{ Terraform: &terraform.TerraformConfig{ Enabled: ptrBool(true), Backend: &terraform.BackendConfig{ Type: "local", }, }, }
DefaultConfig returns the default configuration
var DefaultConfig_Full = v1alpha1.Context{ Environment: map[string]string{}, Docker: commonDockerConfig.Copy(), Git: commonGitConfig.Copy(), Terraform: commonTerraformConfig.Copy(), Cluster: commonClusterConfig.Copy(), Network: &network.NetworkConfig{ CIDRBlock: ptrString(constants.DEFAULT_NETWORK_CIDR), LoadBalancerIPs: &struct { Start *string `yaml:"start,omitempty"` End *string `yaml:"end,omitempty"` }{ Start: ptrString("10.5.1.1"), End: ptrString("10.5.1.10"), }, }, DNS: &dns.DNSConfig{ Enabled: ptrBool(true), Domain: ptrString("test"), Forward: []string{ "10.5.1.1", }, }, }
var DefaultConfig_Localhost = v1alpha1.Context{ Environment: map[string]string{}, Docker: commonDockerConfig.Copy(), Git: commonGitConfig.Copy(), Terraform: commonTerraformConfig.Copy(), Cluster: &cluster.ClusterConfig{ Enabled: ptrBool(true), Driver: ptrString("talos"), ControlPlanes: cluster.NodeGroupConfig{ Count: ptrInt(1), CPU: ptrInt(constants.DEFAULT_TALOS_CONTROL_PLANE_CPU), Memory: ptrInt(constants.DEFAULT_TALOS_CONTROL_PLANE_RAM), Nodes: make(map[string]cluster.NodeConfig), }, Workers: cluster.NodeGroupConfig{ Count: ptrInt(1), CPU: ptrInt(constants.DEFAULT_TALOS_WORKER_CPU), Memory: ptrInt(constants.DEFAULT_TALOS_WORKER_RAM), Nodes: make(map[string]cluster.NodeConfig), HostPorts: []string{"8080:30080/tcp", "8443:30443/tcp", "9292:30292/tcp", "8053:30053/udp"}, Volumes: []string{"${WINDSOR_PROJECT_ROOT}/.volumes:/var/local"}, }, }, Network: &network.NetworkConfig{ CIDRBlock: ptrString(constants.DEFAULT_NETWORK_CIDR), }, DNS: &dns.DNSConfig{ Enabled: ptrBool(true), Domain: ptrString("test"), Forward: []string{ "10.5.0.1:8053", }, }, }
Functions ¶
This section is empty.
Types ¶
type BaseConfigHandler ¶
type BaseConfigHandler struct { ConfigHandler // contains filtered or unexported fields }
BaseConfigHandler is a base implementation of the ConfigHandler interface
func NewBaseConfigHandler ¶ added in v0.3.0
func NewBaseConfigHandler(injector di.Injector) *BaseConfigHandler
NewBaseConfigHandler creates a new BaseConfigHandler instance
func (*BaseConfigHandler) Clean ¶ added in v0.3.0
func (c *BaseConfigHandler) Clean() error
Clean cleans up context specific artifacts
func (*BaseConfigHandler) GetConfigRoot ¶ added in v0.3.0
func (c *BaseConfigHandler) GetConfigRoot() (string, error)
GetConfigRoot retrieves the configuration root path based on the current context
func (*BaseConfigHandler) GetContext ¶ added in v0.3.0
func (c *BaseConfigHandler) GetContext() string
GetContext retrieves the current context from the file or cache
func (*BaseConfigHandler) Initialize ¶ added in v0.3.0
func (c *BaseConfigHandler) Initialize() error
Initialize sets up the config handler by resolving and storing the shell dependency.
func (*BaseConfigHandler) IsLoaded ¶ added in v0.5.0
func (c *BaseConfigHandler) IsLoaded() bool
IsLoaded checks if the configuration has been loaded
func (*BaseConfigHandler) SetContext ¶ added in v0.3.0
func (c *BaseConfigHandler) SetContext(context string) error
SetContext sets the current context in the file and updates the cache
func (*BaseConfigHandler) SetSecretsProvider ¶ added in v0.5.0
func (c *BaseConfigHandler) SetSecretsProvider(provider secrets.SecretsProvider)
SetSecretsProvider sets the secrets provider for the config handler
type ConfigHandler ¶
type ConfigHandler interface { // Initialize initializes the config handler Initialize() error // LoadConfig loads the configuration from the specified path LoadConfig(path string) error // GetString retrieves a string value for the specified key from the configuration GetString(key string, defaultValue ...string) string // GetInt retrieves an integer value for the specified key from the configuration GetInt(key string, defaultValue ...int) int // GetBool retrieves a boolean value for the specified key from the configuration GetBool(key string, defaultValue ...bool) bool // GetStringSlice retrieves a slice of strings for the specified key from the configuration GetStringSlice(key string, defaultValue ...[]string) []string // GetStringMap retrieves a map of string key-value pairs for the specified key from the configuration GetStringMap(key string, defaultValue ...map[string]string) map[string]string // Set sets the value for the specified key in the configuration Set(key string, value interface{}) error // SetContextValue sets the value for the specified key in the configuration SetContextValue(key string, value interface{}) error // Get retrieves a value for the specified key from the configuration Get(key string) interface{} // SaveConfig saves the current configuration to the specified path SaveConfig(path string) error // SetDefault sets the default context configuration SetDefault(context v1alpha1.Context) error // GetConfig returns the context config object GetConfig() *v1alpha1.Context // GetContext retrieves the current context GetContext() string // SetContext sets the current context SetContext(context string) error // GetConfigRoot retrieves the configuration root path based on the current context GetConfigRoot() (string, error) // Clean cleans up context specific artifacts Clean() error // SetSecretsProvider sets the secrets provider for the config handler SetSecretsProvider(provider secrets.SecretsProvider) // IsLoaded checks if the configuration has been loaded IsLoaded() bool }
ConfigHandler defines the interface for handling configuration operations
type MockConfigHandler ¶
type MockConfigHandler struct { InitializeFunc func() error SetSecretsProviderFunc func(provider secrets.SecretsProvider) LoadConfigFunc func(path string) error IsLoadedFunc func() bool GetStringFunc func(key string, defaultValue ...string) string GetIntFunc func(key string, defaultValue ...int) int GetBoolFunc func(key string, defaultValue ...bool) bool GetStringSliceFunc func(key string, defaultValue ...[]string) []string GetStringMapFunc func(key string, defaultValue ...map[string]string) map[string]string SetFunc func(key string, value interface{}) error SetContextValueFunc func(key string, value interface{}) error SaveConfigFunc func(path string) error GetFunc func(key string) interface{} SetDefaultFunc func(context v1alpha1.Context) error GetConfigFunc func() *v1alpha1.Context GetContextFunc func() string SetContextFunc func(context string) error GetConfigRootFunc func() (string, error) CleanFunc func() error }
MockConfigHandler is a mock implementation of the ConfigHandler interface
func NewMockConfigHandler ¶
func NewMockConfigHandler() *MockConfigHandler
NewMockConfigHandler is a constructor for MockConfigHandler
func (*MockConfigHandler) Clean ¶ added in v0.3.0
func (m *MockConfigHandler) Clean() error
Clean calls the mock CleanFunc if set, otherwise returns nil
func (*MockConfigHandler) Get ¶
func (m *MockConfigHandler) Get(key string) interface{}
Get calls the mock GetFunc if set, otherwise returns a reasonable default value
func (*MockConfigHandler) GetBool ¶
func (m *MockConfigHandler) GetBool(key string, defaultValue ...bool) bool
GetBool calls the mock GetBoolFunc if set, otherwise returns a reasonable default bool
func (*MockConfigHandler) GetConfig ¶
func (m *MockConfigHandler) GetConfig() *v1alpha1.Context
GetConfig calls the mock GetConfigFunc if set, otherwise returns a reasonable default Context
func (*MockConfigHandler) GetConfigRoot ¶ added in v0.3.0
func (m *MockConfigHandler) GetConfigRoot() (string, error)
GetConfigRoot calls the mock GetConfigRootFunc if set, otherwise returns a reasonable default string
func (*MockConfigHandler) GetContext ¶ added in v0.3.0
func (m *MockConfigHandler) GetContext() string
GetContext calls the mock GetContextFunc if set, otherwise returns a reasonable default string
func (*MockConfigHandler) GetInt ¶
func (m *MockConfigHandler) GetInt(key string, defaultValue ...int) int
GetInt calls the mock GetIntFunc if set, otherwise returns a reasonable default int
func (*MockConfigHandler) GetString ¶
func (m *MockConfigHandler) GetString(key string, defaultValue ...string) string
GetString calls the mock GetStringFunc if set, otherwise returns a reasonable default string
func (*MockConfigHandler) GetStringMap ¶ added in v0.5.0
func (m *MockConfigHandler) GetStringMap(key string, defaultValue ...map[string]string) map[string]string
GetStringMap calls the mock GetStringMapFunc if set, otherwise returns a reasonable default map of strings
func (*MockConfigHandler) GetStringSlice ¶ added in v0.4.0
func (m *MockConfigHandler) GetStringSlice(key string, defaultValue ...[]string) []string
GetStringSlice calls the mock GetStringSliceFunc if set, otherwise returns a reasonable default slice of strings
func (*MockConfigHandler) Initialize ¶ added in v0.3.0
func (m *MockConfigHandler) Initialize() error
Initialize calls the mock InitializeFunc if set, otherwise returns nil
func (*MockConfigHandler) IsLoaded ¶ added in v0.5.0
func (m *MockConfigHandler) IsLoaded() bool
IsLoaded calls the mock IsLoadedFunc if set, otherwise returns false
func (*MockConfigHandler) LoadConfig ¶
func (m *MockConfigHandler) LoadConfig(path string) error
LoadConfig calls the mock LoadConfigFunc if set, otherwise returns nil
func (*MockConfigHandler) SaveConfig ¶
func (m *MockConfigHandler) SaveConfig(path string) error
SaveConfig calls the mock SaveConfigFunc if set, otherwise returns nil
func (*MockConfigHandler) Set ¶
func (m *MockConfigHandler) Set(key string, value interface{}) error
Set calls the mock SetFunc if set, otherwise returns nil
func (*MockConfigHandler) SetContext ¶ added in v0.3.0
func (m *MockConfigHandler) SetContext(context string) error
SetContext calls the mock SetContextFunc if set, otherwise returns nil
func (*MockConfigHandler) SetContextValue ¶
func (m *MockConfigHandler) SetContextValue(key string, value interface{}) error
SetContextValue calls the mock SetContextValueFunc if set, otherwise returns nil
func (*MockConfigHandler) SetDefault ¶
func (m *MockConfigHandler) SetDefault(context v1alpha1.Context) error
SetDefault calls the mock SetDefaultFunc if set, otherwise does nothing
func (*MockConfigHandler) SetSecretsProvider ¶ added in v0.5.0
func (m *MockConfigHandler) SetSecretsProvider(provider secrets.SecretsProvider)
SetSecretsProvider calls the mock SetSecretsProviderFunc if set, otherwise does nothing
type YamlConfigHandler ¶
type YamlConfigHandler struct { BaseConfigHandler // contains filtered or unexported fields }
YamlConfigHandler implements the ConfigHandler interface using goccy/go-yaml
func NewYamlConfigHandler ¶
func NewYamlConfigHandler(injector di.Injector) *YamlConfigHandler
NewYamlConfigHandler creates a new instance of YamlConfigHandler with default context configuration.
func (*YamlConfigHandler) Get ¶
func (y *YamlConfigHandler) Get(path string) interface{}
Get retrieves the value at the specified path in the configuration. It checks both the current and default context configurations.
func (*YamlConfigHandler) GetBool ¶
func (y *YamlConfigHandler) GetBool(key string, defaultValue ...bool) bool
GetBool retrieves a boolean value for the specified key from the configuration, with an optional default value.
func (*YamlConfigHandler) GetConfig ¶
func (y *YamlConfigHandler) GetConfig() *v1alpha1.Context
GetConfig returns the context config object for the current context, or the default if none is set.
func (*YamlConfigHandler) GetInt ¶
func (y *YamlConfigHandler) GetInt(key string, defaultValue ...int) int
GetInt retrieves an integer value for the specified key from the configuration, with an optional default value.
func (*YamlConfigHandler) GetString ¶
func (y *YamlConfigHandler) GetString(key string, defaultValue ...string) string
GetString retrieves a string value for the specified key from the configuration, with an optional default value. If the key is not found, it returns the provided default value or an empty string if no default is provided.
func (*YamlConfigHandler) GetStringMap ¶ added in v0.5.0
func (y *YamlConfigHandler) GetStringMap(key string, defaultValue ...map[string]string) map[string]string
GetStringMap retrieves a map of string key-value pairs for the specified key from the configuration. If the key is not found, it returns the provided default value or an empty map if no default is provided.
func (*YamlConfigHandler) GetStringSlice ¶ added in v0.4.0
func (y *YamlConfigHandler) GetStringSlice(key string, defaultValue ...[]string) []string
GetStringSlice retrieves a slice of strings for the specified key from the configuration, with an optional default value. If the key is not found, it returns the provided default value or an empty slice if no default is provided.
func (*YamlConfigHandler) LoadConfig ¶
func (y *YamlConfigHandler) LoadConfig(path string) error
LoadConfig loads the configuration from the specified path. If the file does not exist, it does nothing.
func (*YamlConfigHandler) SaveConfig ¶
func (y *YamlConfigHandler) SaveConfig(path string) error
SaveConfig saves the current configuration to the specified path. If the path is empty, it uses the previously loaded path. If the file does not exist, it creates an empty one.
func (*YamlConfigHandler) Set ¶
func (y *YamlConfigHandler) Set(path string, value interface{}) error
Set updates the value at the specified path in the configuration using reflection.
func (*YamlConfigHandler) SetContextValue ¶
func (y *YamlConfigHandler) SetContextValue(path string, value interface{}) error
SetContextValue sets a configuration value within the current context.
func (*YamlConfigHandler) SetDefault ¶
func (y *YamlConfigHandler) SetDefault(context v1alpha1.Context) error
SetDefault sets the given context configuration as the default.