Documentation
¶
Overview ¶
Package config contains the definition of the application config structure and logic required to load and update it.
Index ¶
- Constants
- func DetectRegistryType(input string, allowPrivateIPs bool) (registryType string, cleanPath string)
- func ResetSingleton()
- func SetSingletonConfig(cfg *Config)
- func UpdateConfig(updateFn func(*Config)) error
- func UpdateConfigAtPath(configPath string, updateFn func(*Config)) error
- func ValidateBuildEnvEntry(key, value string) error
- func ValidateBuildEnvKey(key string) error
- func ValidateBuildEnvValue(value string) error
- type Clients
- type Config
- type DefaultProvider
- func (d *DefaultProvider) GetAllBuildEnv() map[string]string
- func (d *DefaultProvider) GetBuildEnv(key string) (value string, exists bool)
- func (d *DefaultProvider) GetCACert() (certPath string, exists bool, accessible bool)
- func (*DefaultProvider) GetConfig() *Config
- func (d *DefaultProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
- func (*DefaultProvider) LoadOrCreateConfig() (*Config, error)
- func (d *DefaultProvider) SetBuildEnv(key, value string) error
- func (d *DefaultProvider) SetCACert(certPath string) error
- func (d *DefaultProvider) SetRegistryAPI(apiURL string, allowPrivateRegistryIp bool) error
- func (d *DefaultProvider) SetRegistryFile(registryPath string) error
- func (d *DefaultProvider) SetRegistryURL(registryURL string, allowPrivateRegistryIp bool) error
- func (d *DefaultProvider) UnsetAllBuildEnv() error
- func (d *DefaultProvider) UnsetBuildEnv(key string) error
- func (d *DefaultProvider) UnsetCACert() error
- func (d *DefaultProvider) UnsetRegistry() error
- func (*DefaultProvider) UpdateConfig(updateFn func(*Config)) error
- type KubernetesProvider
- func (*KubernetesProvider) GetAllBuildEnv() map[string]string
- func (*KubernetesProvider) GetBuildEnv(_ string) (value string, exists bool)
- func (*KubernetesProvider) GetCACert() (certPath string, exists bool, accessible bool)
- func (*KubernetesProvider) GetConfig() *Config
- func (*KubernetesProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
- func (*KubernetesProvider) LoadOrCreateConfig() (*Config, error)
- func (*KubernetesProvider) SetBuildEnv(_, _ string) error
- func (*KubernetesProvider) SetCACert(_ string) error
- func (*KubernetesProvider) SetRegistryAPI(_ string, _ bool) error
- func (*KubernetesProvider) SetRegistryFile(_ string) error
- func (*KubernetesProvider) SetRegistryURL(_ string, _ bool) error
- func (*KubernetesProvider) UnsetAllBuildEnv() error
- func (*KubernetesProvider) UnsetBuildEnv(_ string) error
- func (*KubernetesProvider) UnsetCACert() error
- func (*KubernetesProvider) UnsetRegistry() error
- func (*KubernetesProvider) UpdateConfig(_ func(*Config)) error
- type OpenTelemetryConfig
- type PathProvider
- func (p *PathProvider) GetAllBuildEnv() map[string]string
- func (p *PathProvider) GetBuildEnv(key string) (value string, exists bool)
- func (p *PathProvider) GetCACert() (certPath string, exists bool, accessible bool)
- func (p *PathProvider) GetConfig() *Config
- func (p *PathProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
- func (p *PathProvider) LoadOrCreateConfig() (*Config, error)
- func (p *PathProvider) SetBuildEnv(key, value string) error
- func (p *PathProvider) SetCACert(certPath string) error
- func (p *PathProvider) SetRegistryAPI(apiURL string, allowPrivateRegistryIp bool) error
- func (p *PathProvider) SetRegistryFile(registryPath string) error
- func (p *PathProvider) SetRegistryURL(registryURL string, allowPrivateRegistryIp bool) error
- func (p *PathProvider) UnsetAllBuildEnv() error
- func (p *PathProvider) UnsetBuildEnv(key string) error
- func (p *PathProvider) UnsetCACert() error
- func (p *PathProvider) UnsetRegistry() error
- func (p *PathProvider) UpdateConfig(updateFn func(*Config)) error
- type Provider
- type Secrets
Constants ¶
const ( // RegistryTypeFile represents a local file registry RegistryTypeFile = "file" // RegistryTypeURL represents a remote URL registry RegistryTypeURL = "url" // RegistryTypeAPI represents an MCP Registry API endpoint RegistryTypeAPI = "api" )
Variables ¶
This section is empty.
Functions ¶
func DetectRegistryType ¶ added in v0.2.4
DetectRegistryType determines if input is a URL or file path and returns cleaned path
func ResetSingleton ¶ added in v0.2.16
func ResetSingleton()
ResetSingleton clears the singleton - useful for test cleanup
func SetSingletonConfig ¶ added in v0.2.16
func SetSingletonConfig(cfg *Config)
SetSingletonConfig allows tests to pre-initialize the singleton with test data This prevents the singleton from loading the real config file during tests
func UpdateConfig ¶ added in v0.0.32
UpdateConfig locks a separate lock file, reads from disk, applies the changes from the anonymous function, writes to disk and unlocks the file.
func UpdateConfigAtPath ¶ added in v0.0.45
UpdateConfigAtPath locks a separate lock file, reads from disk, applies the changes from the anonymous function, writes to disk and unlocks the file. If configPath is empty, it uses the default path.
func ValidateBuildEnvEntry ¶ added in v0.6.8
ValidateBuildEnvEntry validates both the key and value of a build environment variable.
func ValidateBuildEnvKey ¶ added in v0.6.8
ValidateBuildEnvKey validates that an environment variable key follows the required pattern and is not a reserved variable.
func ValidateBuildEnvValue ¶ added in v0.6.8
ValidateBuildEnvValue validates that an environment variable value does not contain potentially dangerous characters that could enable shell injection in Dockerfiles.
Types ¶
type Clients ¶
type Clients struct {
RegisteredClients []string `yaml:"registered_clients"`
AutoDiscovery bool `yaml:"auto_discovery"` // Deprecated: kept for migration purposes only
}
Clients contains settings for client configuration.
type Config ¶
type Config struct {
Secrets Secrets `yaml:"secrets"`
Clients Clients `yaml:"clients"`
RegistryUrl string `yaml:"registry_url"`
RegistryApiUrl string `yaml:"registry_api_url"`
LocalRegistryPath string `yaml:"local_registry_path"`
AllowPrivateRegistryIp bool `yaml:"allow_private_registry_ip"`
CACertificatePath string `yaml:"ca_certificate_path,omitempty"`
OTEL OpenTelemetryConfig `yaml:"otel,omitempty"`
DefaultGroupMigration bool `yaml:"default_group_migration,omitempty"`
DisableUsageMetrics bool `yaml:"disable_usage_metrics,omitempty"`
BuildEnv map[string]string `yaml:"build_env,omitempty"`
}
Config represents the configuration of the application.
func LoadOrCreateConfig ¶
LoadOrCreateConfig fetches the application configuration. If it does not already exist - it will create a new config file with default values.
func LoadOrCreateConfigFromPath ¶ added in v0.2.17
LoadOrCreateConfigFromPath is the core implementation for loading/creating config from a specific path
func LoadOrCreateConfigWithDefaultPath ¶ added in v0.2.17
LoadOrCreateConfigWithDefaultPath is the internal implementation for loading config with the default path. This avoids circular dependency issues.
func LoadOrCreateConfigWithPath ¶ added in v0.0.45
LoadOrCreateConfigWithPath fetches the application configuration from a specific path. If configPath is empty, it uses the default path. If it does not already exist - it will create a new config file with default values.
type DefaultProvider ¶ added in v0.2.14
type DefaultProvider struct{}
DefaultProvider implements Provider using the default XDG config path
func NewDefaultProvider ¶ added in v0.2.14
func NewDefaultProvider() *DefaultProvider
NewDefaultProvider creates a new default config provider
func (*DefaultProvider) GetAllBuildEnv ¶ added in v0.6.8
func (d *DefaultProvider) GetAllBuildEnv() map[string]string
GetAllBuildEnv returns all build environment variables
func (*DefaultProvider) GetBuildEnv ¶ added in v0.6.8
func (d *DefaultProvider) GetBuildEnv(key string) (value string, exists bool)
GetBuildEnv returns a specific build environment variable
func (*DefaultProvider) GetCACert ¶ added in v0.6.0
func (d *DefaultProvider) GetCACert() (certPath string, exists bool, accessible bool)
GetCACert returns the currently configured CA certificate path and its accessibility status
func (*DefaultProvider) GetConfig ¶ added in v0.2.14
func (*DefaultProvider) GetConfig() *Config
GetConfig returns the singleton config (for backward compatibility)
func (*DefaultProvider) GetRegistryConfig ¶ added in v0.2.16
func (d *DefaultProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
GetRegistryConfig returns current registry configuration
func (*DefaultProvider) LoadOrCreateConfig ¶ added in v0.2.14
func (*DefaultProvider) LoadOrCreateConfig() (*Config, error)
LoadOrCreateConfig loads or creates config using the default path
func (*DefaultProvider) SetBuildEnv ¶ added in v0.6.8
func (d *DefaultProvider) SetBuildEnv(key, value string) error
SetBuildEnv validates and sets a build environment variable
func (*DefaultProvider) SetCACert ¶ added in v0.6.0
func (d *DefaultProvider) SetCACert(certPath string) error
SetCACert validates and sets the CA certificate path
func (*DefaultProvider) SetRegistryAPI ¶ added in v0.6.3
func (d *DefaultProvider) SetRegistryAPI(apiURL string, allowPrivateRegistryIp bool) error
SetRegistryAPI validates and sets an MCP Registry API endpoint
func (*DefaultProvider) SetRegistryFile ¶ added in v0.2.16
func (d *DefaultProvider) SetRegistryFile(registryPath string) error
SetRegistryFile validates and sets a local registry file
func (*DefaultProvider) SetRegistryURL ¶ added in v0.2.16
func (d *DefaultProvider) SetRegistryURL(registryURL string, allowPrivateRegistryIp bool) error
SetRegistryURL validates and sets a registry URL
func (*DefaultProvider) UnsetAllBuildEnv ¶ added in v0.6.8
func (d *DefaultProvider) UnsetAllBuildEnv() error
UnsetAllBuildEnv removes all build environment variables
func (*DefaultProvider) UnsetBuildEnv ¶ added in v0.6.8
func (d *DefaultProvider) UnsetBuildEnv(key string) error
UnsetBuildEnv removes a specific build environment variable
func (*DefaultProvider) UnsetCACert ¶ added in v0.6.0
func (d *DefaultProvider) UnsetCACert() error
UnsetCACert removes the CA certificate configuration
func (*DefaultProvider) UnsetRegistry ¶ added in v0.2.16
func (d *DefaultProvider) UnsetRegistry() error
UnsetRegistry resets registry configuration to defaults
func (*DefaultProvider) UpdateConfig ¶ added in v0.2.14
func (*DefaultProvider) UpdateConfig(updateFn func(*Config)) error
UpdateConfig updates the config using the default path
type KubernetesProvider ¶ added in v0.2.17
type KubernetesProvider struct{}
KubernetesProvider is a no-op implementation of Provider for Kubernetes environments. In Kubernetes, configuration is managed by the cluster, not by local files.
func NewKubernetesProvider ¶ added in v0.2.17
func NewKubernetesProvider() *KubernetesProvider
NewKubernetesProvider creates a new no-op config provider for Kubernetes environments
func (*KubernetesProvider) GetAllBuildEnv ¶ added in v0.6.8
func (*KubernetesProvider) GetAllBuildEnv() map[string]string
GetAllBuildEnv returns empty map for Kubernetes environments
func (*KubernetesProvider) GetBuildEnv ¶ added in v0.6.8
func (*KubernetesProvider) GetBuildEnv(_ string) (value string, exists bool)
GetBuildEnv returns empty for Kubernetes environments
func (*KubernetesProvider) GetCACert ¶ added in v0.6.0
func (*KubernetesProvider) GetCACert() (certPath string, exists bool, accessible bool)
GetCACert returns empty CA cert configuration for Kubernetes environments
func (*KubernetesProvider) GetConfig ¶ added in v0.2.17
func (*KubernetesProvider) GetConfig() *Config
GetConfig returns a default config for Kubernetes environments
func (*KubernetesProvider) GetRegistryConfig ¶ added in v0.2.17
func (*KubernetesProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
GetRegistryConfig returns empty registry configuration for Kubernetes environments
func (*KubernetesProvider) LoadOrCreateConfig ¶ added in v0.2.17
func (*KubernetesProvider) LoadOrCreateConfig() (*Config, error)
LoadOrCreateConfig returns a default config for Kubernetes environments
func (*KubernetesProvider) SetBuildEnv ¶ added in v0.6.8
func (*KubernetesProvider) SetBuildEnv(_, _ string) error
SetBuildEnv is a no-op for Kubernetes environments
func (*KubernetesProvider) SetCACert ¶ added in v0.6.0
func (*KubernetesProvider) SetCACert(_ string) error
SetCACert is a no-op for Kubernetes environments
func (*KubernetesProvider) SetRegistryAPI ¶ added in v0.6.3
func (*KubernetesProvider) SetRegistryAPI(_ string, _ bool) error
SetRegistryAPI is a no-op for Kubernetes environments
func (*KubernetesProvider) SetRegistryFile ¶ added in v0.2.17
func (*KubernetesProvider) SetRegistryFile(_ string) error
SetRegistryFile is a no-op for Kubernetes environments
func (*KubernetesProvider) SetRegistryURL ¶ added in v0.2.17
func (*KubernetesProvider) SetRegistryURL(_ string, _ bool) error
SetRegistryURL is a no-op for Kubernetes environments
func (*KubernetesProvider) UnsetAllBuildEnv ¶ added in v0.6.8
func (*KubernetesProvider) UnsetAllBuildEnv() error
UnsetAllBuildEnv is a no-op for Kubernetes environments
func (*KubernetesProvider) UnsetBuildEnv ¶ added in v0.6.8
func (*KubernetesProvider) UnsetBuildEnv(_ string) error
UnsetBuildEnv is a no-op for Kubernetes environments
func (*KubernetesProvider) UnsetCACert ¶ added in v0.6.0
func (*KubernetesProvider) UnsetCACert() error
UnsetCACert is a no-op for Kubernetes environments
func (*KubernetesProvider) UnsetRegistry ¶ added in v0.2.17
func (*KubernetesProvider) UnsetRegistry() error
UnsetRegistry is a no-op for Kubernetes environments
func (*KubernetesProvider) UpdateConfig ¶ added in v0.2.17
func (*KubernetesProvider) UpdateConfig(_ func(*Config)) error
UpdateConfig is a no-op for Kubernetes environments
type OpenTelemetryConfig ¶ added in v0.1.2
type OpenTelemetryConfig struct {
Endpoint string `yaml:"endpoint,omitempty"`
SamplingRate float64 `yaml:"sampling-rate,omitempty"`
EnvVars []string `yaml:"env-vars,omitempty"`
MetricsEnabled bool `yaml:"metrics-enabled,omitempty"`
TracingEnabled bool `yaml:"tracing-enabled,omitempty"`
Insecure bool `yaml:"insecure,omitempty"`
EnablePrometheusMetricsPath bool `yaml:"enable-prometheus-metrics-path,omitempty"`
}
OpenTelemetryConfig contains the settings for OpenTelemetry configuration.
type PathProvider ¶ added in v0.2.14
type PathProvider struct {
// contains filtered or unexported fields
}
PathProvider implements Provider using a specific config path
func NewPathProvider ¶ added in v0.2.14
func NewPathProvider(configPath string) *PathProvider
NewPathProvider creates a new config provider with a specific path
func (*PathProvider) GetAllBuildEnv ¶ added in v0.6.8
func (p *PathProvider) GetAllBuildEnv() map[string]string
GetAllBuildEnv returns all build environment variables
func (*PathProvider) GetBuildEnv ¶ added in v0.6.8
func (p *PathProvider) GetBuildEnv(key string) (value string, exists bool)
GetBuildEnv returns a specific build environment variable
func (*PathProvider) GetCACert ¶ added in v0.6.0
func (p *PathProvider) GetCACert() (certPath string, exists bool, accessible bool)
GetCACert returns the currently configured CA certificate path and its accessibility status
func (*PathProvider) GetConfig ¶ added in v0.2.14
func (p *PathProvider) GetConfig() *Config
GetConfig loads and returns the config from the specific path
func (*PathProvider) GetRegistryConfig ¶ added in v0.2.16
func (p *PathProvider) GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
GetRegistryConfig returns current registry configuration
func (*PathProvider) LoadOrCreateConfig ¶ added in v0.2.14
func (p *PathProvider) LoadOrCreateConfig() (*Config, error)
LoadOrCreateConfig loads or creates config at the specific path
func (*PathProvider) SetBuildEnv ¶ added in v0.6.8
func (p *PathProvider) SetBuildEnv(key, value string) error
SetBuildEnv validates and sets a build environment variable
func (*PathProvider) SetCACert ¶ added in v0.6.0
func (p *PathProvider) SetCACert(certPath string) error
SetCACert validates and sets the CA certificate path
func (*PathProvider) SetRegistryAPI ¶ added in v0.6.3
func (p *PathProvider) SetRegistryAPI(apiURL string, allowPrivateRegistryIp bool) error
SetRegistryAPI validates and sets an MCP Registry API endpoint
func (*PathProvider) SetRegistryFile ¶ added in v0.2.16
func (p *PathProvider) SetRegistryFile(registryPath string) error
SetRegistryFile validates and sets a local registry file
func (*PathProvider) SetRegistryURL ¶ added in v0.2.16
func (p *PathProvider) SetRegistryURL(registryURL string, allowPrivateRegistryIp bool) error
SetRegistryURL validates and sets a registry URL
func (*PathProvider) UnsetAllBuildEnv ¶ added in v0.6.8
func (p *PathProvider) UnsetAllBuildEnv() error
UnsetAllBuildEnv removes all build environment variables
func (*PathProvider) UnsetBuildEnv ¶ added in v0.6.8
func (p *PathProvider) UnsetBuildEnv(key string) error
UnsetBuildEnv removes a specific build environment variable
func (*PathProvider) UnsetCACert ¶ added in v0.6.0
func (p *PathProvider) UnsetCACert() error
UnsetCACert removes the CA certificate configuration
func (*PathProvider) UnsetRegistry ¶ added in v0.2.16
func (p *PathProvider) UnsetRegistry() error
UnsetRegistry resets registry configuration to defaults
func (*PathProvider) UpdateConfig ¶ added in v0.2.14
func (p *PathProvider) UpdateConfig(updateFn func(*Config)) error
UpdateConfig updates the config at the specific path
type Provider ¶ added in v0.2.14
type Provider interface {
GetConfig() *Config
UpdateConfig(updateFn func(*Config)) error
LoadOrCreateConfig() (*Config, error)
// Registry operations
SetRegistryURL(registryURL string, allowPrivateRegistryIp bool) error
SetRegistryAPI(apiURL string, allowPrivateRegistryIp bool) error
SetRegistryFile(registryPath string) error
UnsetRegistry() error
GetRegistryConfig() (url, localPath string, allowPrivateIP bool, registryType string)
// CA certificate operations
SetCACert(certPath string) error
GetCACert() (certPath string, exists bool, accessible bool)
UnsetCACert() error
// Build environment operations
SetBuildEnv(key, value string) error
GetBuildEnv(key string) (value string, exists bool)
GetAllBuildEnv() map[string]string
UnsetBuildEnv(key string) error
UnsetAllBuildEnv() error
}
Provider defines the interface for configuration operations
func NewProvider ¶ added in v0.2.17
func NewProvider() Provider
NewProvider creates the appropriate config provider based on the runtime environment
type Secrets ¶
type Secrets struct {
ProviderType string `yaml:"provider_type"`
SetupCompleted bool `yaml:"setup_completed"`
}
Secrets contains the settings for secrets management.
func (*Secrets) GetProviderType ¶ added in v0.0.33
func (s *Secrets) GetProviderType() (secrets.ProviderType, error)
GetProviderType returns the secrets provider type from the environment variable or application config. It first checks the TOOLHIVE_SECRETS_PROVIDER environment variable, and falls back to the config file. Returns ErrSecretsNotSetup if secrets have not been configured yet.
func (*Secrets) GetProviderTypeWithEnv ¶ added in v0.2.13
GetProviderTypeWithEnv returns the secrets provider type using the provided environment reader. This method allows for dependency injection of environment variable access for testing.