Documentation
¶
Index ¶
- func ExampleFileSource_expandEnvWithDefaults()
- func NewConsulSource(prefix string, options ConsulSourceOptions) (configcore.ConfigSource, error)
- func NewEnvSource(prefix string, options EnvSourceOptions) (configcore.ConfigSource, error)
- func NewFileSource(path string, options FileSourceOptions) (configcore.ConfigSource, error)
- func NewK8sSource(options K8sSourceOptions) (configcore.ConfigSource, error)
- func TestRealConfigExample_MixedDefaults(t *testing.T)
- func TestRealConfigExample_WithDefaults(t *testing.T)
- func TestRealConfigExample_WithEnvOverrides(t *testing.T)
- type ConsulSource
- func (cs *ConsulSource) GetName() string
- func (cs *ConsulSource) GetSecret(ctx context.Context, key string) (string, error)
- func (cs *ConsulSource) GetType() string
- func (cs *ConsulSource) IsAvailable(ctx context.Context) bool
- func (cs *ConsulSource) IsWatchable() bool
- func (cs *ConsulSource) Load(ctx context.Context) (map[string]any, error)
- func (cs *ConsulSource) Name() string
- func (cs *ConsulSource) Priority() int
- func (cs *ConsulSource) Reload(ctx context.Context) error
- func (cs *ConsulSource) StopWatch() error
- func (cs *ConsulSource) SupportsSecrets() bool
- func (cs *ConsulSource) Watch(ctx context.Context, callback func(map[string]any)) error
- type ConsulSourceConfig
- type ConsulSourceFactory
- type ConsulSourceOptions
- type ConsulTLSConfig
- type EnvSource
- func (es *EnvSource) GetKeyMapping() map[string]string
- func (es *EnvSource) GetName() string
- func (es *EnvSource) GetPrefix() string
- func (es *EnvSource) GetSecret(ctx context.Context, key string) (string, error)
- func (es *EnvSource) GetSeparator() string
- func (es *EnvSource) GetType() string
- func (es *EnvSource) IsAvailable(ctx context.Context) bool
- func (es *EnvSource) IsWatchable() bool
- func (es *EnvSource) IsWatching() bool
- func (es *EnvSource) Load(ctx context.Context) (map[string]any, error)
- func (es *EnvSource) Name() string
- func (es *EnvSource) Priority() int
- func (es *EnvSource) Reload(ctx context.Context) error
- func (es *EnvSource) StopWatch() error
- func (es *EnvSource) SupportsSecrets() bool
- func (es *EnvSource) Watch(ctx context.Context, callback func(map[string]any)) error
- type EnvSourceConfig
- type EnvSourceFactory
- type EnvSourceOptions
- type FileSource
- func (fs *FileSource) GetFormat() string
- func (fs *FileSource) GetLastModTime() time.Time
- func (fs *FileSource) GetName() string
- func (fs *FileSource) GetPath() string
- func (fs *FileSource) GetSecret(ctx context.Context, key string) (string, error)
- func (fs *FileSource) GetType() string
- func (fs *FileSource) IsAvailable(ctx context.Context) bool
- func (fs *FileSource) IsWatchable() bool
- func (fs *FileSource) IsWatching() bool
- func (fs *FileSource) Load(ctx context.Context) (map[string]any, error)
- func (fs *FileSource) Name() string
- func (fs *FileSource) Priority() int
- func (fs *FileSource) Reload(ctx context.Context) error
- func (fs *FileSource) StopWatch() error
- func (fs *FileSource) SupportsSecrets() bool
- func (fs *FileSource) Watch(ctx context.Context, callback func(map[string]any)) error
- type FileSourceConfig
- type FileSourceFactory
- type FileSourceOptions
- type K8sSource
- func (ks *K8sSource) GetName() string
- func (ks *K8sSource) GetSecret(ctx context.Context, key string) (string, error)
- func (ks *K8sSource) GetType() string
- func (ks *K8sSource) IsAvailable(ctx context.Context) bool
- func (ks *K8sSource) IsWatchable() bool
- func (ks *K8sSource) Load(ctx context.Context) (map[string]any, error)
- func (ks *K8sSource) Name() string
- func (ks *K8sSource) Priority() int
- func (ks *K8sSource) Reload(ctx context.Context) error
- func (ks *K8sSource) StopWatch() error
- func (ks *K8sSource) SupportsSecrets() bool
- func (ks *K8sSource) Watch(ctx context.Context, callback func(map[string]any)) error
- type K8sSourceConfig
- type K8sSourceFactory
- type K8sSourceOptions
- type KeyTransformFunc
- type ValueTransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExampleFileSource_expandEnvWithDefaults ¶ added in v0.8.5
func ExampleFileSource_expandEnvWithDefaults()
func NewConsulSource ¶
func NewConsulSource(prefix string, options ConsulSourceOptions) (configcore.ConfigSource, error)
NewConsulSource creates a new Consul configuration source.
func NewEnvSource ¶
func NewEnvSource(prefix string, options EnvSourceOptions) (configcore.ConfigSource, error)
NewEnvSource creates a new environment variable configuration source.
func NewFileSource ¶
func NewFileSource(path string, options FileSourceOptions) (configcore.ConfigSource, error)
NewFileSource creates a new file-based configuration source.
func NewK8sSource ¶
func NewK8sSource(options K8sSourceOptions) (configcore.ConfigSource, error)
NewK8sSource creates a new Kubernetes configuration source.
func TestRealConfigExample_MixedDefaults ¶ added in v0.8.5
func TestRealConfigExample_WithDefaults ¶ added in v0.8.5
func TestRealConfigExample_WithEnvOverrides ¶ added in v0.8.5
Types ¶
type ConsulSource ¶
type ConsulSource struct {
// contains filtered or unexported fields
}
ConsulSource represents a Consul configuration source.
func (*ConsulSource) GetName ¶
func (cs *ConsulSource) GetName() string
GetName returns the source name (alias for Name).
func (*ConsulSource) GetType ¶
func (cs *ConsulSource) GetType() string
GetType returns the source type.
func (*ConsulSource) IsAvailable ¶
func (cs *ConsulSource) IsAvailable(ctx context.Context) bool
IsAvailable checks if the source is available.
func (*ConsulSource) IsWatchable ¶
func (cs *ConsulSource) IsWatchable() bool
IsWatchable returns true if Consul watching is enabled.
func (*ConsulSource) Priority ¶
func (cs *ConsulSource) Priority() int
Priority returns the source priority.
func (*ConsulSource) Reload ¶
func (cs *ConsulSource) Reload(ctx context.Context) error
Reload forces a reload of Consul configuration.
func (*ConsulSource) StopWatch ¶
func (cs *ConsulSource) StopWatch() error
StopWatch stops watching Consul KV.
func (*ConsulSource) SupportsSecrets ¶
func (cs *ConsulSource) SupportsSecrets() bool
SupportsSecrets returns true (Consul can store secrets).
type ConsulSourceConfig ¶
type ConsulSourceConfig struct {
Address string `json:"address" yaml:"address"`
Token string `json:"token" yaml:"token"`
Datacenter string `json:"datacenter" yaml:"datacenter"`
Prefix string `json:"prefix" yaml:"prefix"`
Priority int `json:"priority" yaml:"priority"`
WatchEnabled bool `json:"watch_enabled" yaml:"watch_enabled"`
Timeout time.Duration `json:"timeout" yaml:"timeout"`
RetryCount int `json:"retry_count" yaml:"retry_count"`
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
TLS *ConsulTLSConfig `json:"tls" yaml:"tls"`
}
ConsulSourceConfig contains configuration for creating Consul sources.
type ConsulSourceFactory ¶
type ConsulSourceFactory struct {
// contains filtered or unexported fields
}
ConsulSourceFactory creates Consul configuration sources.
func NewConsulSourceFactory ¶
func NewConsulSourceFactory(logger logger.Logger, errorHandler shared.ErrorHandler) *ConsulSourceFactory
NewConsulSourceFactory creates a new Consul source factory.
func (*ConsulSourceFactory) CreateFromConfig ¶
func (factory *ConsulSourceFactory) CreateFromConfig(config ConsulSourceConfig) (configcore.ConfigSource, error)
CreateFromConfig creates a Consul source from configuration.
func (*ConsulSourceFactory) CreateWithDefaults ¶
func (factory *ConsulSourceFactory) CreateWithDefaults(prefix string) (configcore.ConfigSource, error)
CreateWithDefaults creates a Consul source with default settings.
type ConsulSourceOptions ¶
type ConsulSourceOptions struct {
Name string
Address string
Token string
Datacenter string
Prefix string
Priority int
WatchEnabled bool
Timeout time.Duration
RetryCount int
RetryDelay time.Duration
TLS *ConsulTLSConfig
Logger logger.Logger
ErrorHandler shared.ErrorHandler
}
ConsulSourceOptions contains options for Consul configuration sources.
type ConsulTLSConfig ¶
type ConsulTLSConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"`
CertFile string `json:"cert_file" yaml:"cert_file"`
KeyFile string `json:"key_file" yaml:"key_file"`
CAFile string `json:"ca_file" yaml:"ca_file"`
InsecureSkipVerify bool `json:"insecure_skip_verify" yaml:"insecure_skip_verify"`
}
ConsulTLSConfig contains TLS configuration for Consul.
type EnvSource ¶
type EnvSource struct {
// contains filtered or unexported fields
}
EnvSource represents an environment variable configuration source.
func (*EnvSource) GetKeyMapping ¶
GetKeyMapping returns the key mapping configuration.
func (*EnvSource) GetSeparator ¶
GetSeparator returns the key separator.
func (*EnvSource) IsAvailable ¶
IsAvailable checks if the source is available.
func (*EnvSource) IsWatchable ¶
IsWatchable returns true if environment watching is enabled.
func (*EnvSource) IsWatching ¶
IsWatching returns true if the source is watching for changes.
func (*EnvSource) SupportsSecrets ¶
SupportsSecrets returns true if secret variables are configured.
type EnvSourceConfig ¶
type EnvSourceConfig struct {
Prefix string `json:"prefix" yaml:"prefix"`
Priority int `json:"priority" yaml:"priority"`
Separator string `json:"separator" yaml:"separator"`
WatchEnabled bool `json:"watch_enabled" yaml:"watch_enabled"`
WatchInterval time.Duration `json:"watch_interval" yaml:"watch_interval"`
CaseSensitive bool `json:"case_sensitive" yaml:"case_sensitive"`
IgnoreEmpty bool `json:"ignore_empty" yaml:"ignore_empty"`
TypeConversion bool `json:"type_conversion" yaml:"type_conversion"`
RequiredVars []string `json:"required_vars" yaml:"required_vars"`
SecretVars []string `json:"secret_vars" yaml:"secret_vars"`
KeyMapping map[string]string `json:"key_mapping" yaml:"key_mapping"`
}
EnvSourceConfig contains configuration for creating environment variable sources.
type EnvSourceFactory ¶
type EnvSourceFactory struct {
// contains filtered or unexported fields
}
EnvSourceFactory creates environment variable sources.
func NewEnvSourceFactory ¶
func NewEnvSourceFactory(logger logger.Logger, errorHandler shared.ErrorHandler) *EnvSourceFactory
NewEnvSourceFactory creates a new environment variable source factory.
func (*EnvSourceFactory) CreateFromConfig ¶
func (factory *EnvSourceFactory) CreateFromConfig(config EnvSourceConfig) (configcore.ConfigSource, error)
CreateFromConfig creates an environment variable source from configuration.
func (*EnvSourceFactory) CreateWithDefaults ¶
func (factory *EnvSourceFactory) CreateWithDefaults(prefix string) (configcore.ConfigSource, error)
CreateWithDefaults creates an environment variable source with default settings.
type EnvSourceOptions ¶
type EnvSourceOptions struct {
Name string
Prefix string
Priority int
Separator string
WatchEnabled bool
WatchInterval time.Duration
CaseSensitive bool
IgnoreEmpty bool
TypeConversion bool
KeyTransform KeyTransformFunc
ValueTransform ValueTransformFunc
KeyMapping map[string]string
ValueMapping map[string]func(string) any
RequiredVars []string
SecretVars []string
Logger logger.Logger
ErrorHandler shared.ErrorHandler
}
EnvSourceOptions contains options for environment variable sources.
type FileSource ¶
type FileSource struct {
// contains filtered or unexported fields
}
FileSource represents a file-based configuration source.
func (*FileSource) GetFormat ¶
func (fs *FileSource) GetFormat() string
GetFormat returns the file format.
func (*FileSource) GetLastModTime ¶
func (fs *FileSource) GetLastModTime() time.Time
GetLastModTime returns the last modification time.
func (*FileSource) GetName ¶
func (fs *FileSource) GetName() string
GetName returns the source name (alias for Name).
func (*FileSource) GetType ¶
func (fs *FileSource) GetType() string
GetType returns the source type.
func (*FileSource) IsAvailable ¶
func (fs *FileSource) IsAvailable(ctx context.Context) bool
IsAvailable checks if the source is available.
func (*FileSource) IsWatchable ¶
func (fs *FileSource) IsWatchable() bool
IsWatchable returns true if file watching is enabled.
func (*FileSource) IsWatching ¶
func (fs *FileSource) IsWatching() bool
IsWatching returns true if the file is being watched.
func (*FileSource) Priority ¶
func (fs *FileSource) Priority() int
Priority returns the source priority.
func (*FileSource) Reload ¶
func (fs *FileSource) Reload(ctx context.Context) error
Reload forces a reload of the file.
func (*FileSource) StopWatch ¶
func (fs *FileSource) StopWatch() error
StopWatch stops watching the file.
func (*FileSource) SupportsSecrets ¶
func (fs *FileSource) SupportsSecrets() bool
SupportsSecrets returns true if secret expansion is enabled.
type FileSourceConfig ¶
type FileSourceConfig struct {
Path string `json:"path" yaml:"path"`
Format string `json:"format" yaml:"format"`
Priority int `json:"priority" yaml:"priority"`
WatchEnabled bool `json:"watch_enabled" yaml:"watch_enabled"`
WatchInterval time.Duration `json:"watch_interval" yaml:"watch_interval"`
ExpandEnvVars bool `json:"expand_env_vars" yaml:"expand_env_vars"`
ExpandSecrets bool `json:"expand_secrets" yaml:"expand_secrets"`
RequireFile bool `json:"require_file" yaml:"require_file"`
BackupEnabled bool `json:"backup_enabled" yaml:"backup_enabled"`
BackupDir string `json:"backup_dir" yaml:"backup_dir"`
}
FileSourceConfig contains configuration for creating file sources.
type FileSourceFactory ¶
type FileSourceFactory struct {
// contains filtered or unexported fields
}
FileSourceFactory creates file sources.
func NewFileSourceFactory ¶
func NewFileSourceFactory(logger logger.Logger, errorHandler shared.ErrorHandler) *FileSourceFactory
NewFileSourceFactory creates a new file source factory.
func (*FileSourceFactory) CreateFromConfig ¶
func (factory *FileSourceFactory) CreateFromConfig(config FileSourceConfig) (configcore.ConfigSource, error)
CreateFromConfig creates a file source from configuration.
func (*FileSourceFactory) CreateMultiple ¶
func (factory *FileSourceFactory) CreateMultiple(configs []FileSourceConfig) ([]configcore.ConfigSource, error)
CreateMultiple creates multiple file sources from configurations.
type FileSourceOptions ¶
type FileSourceOptions struct {
Name string
Format string
Priority int
WatchEnabled bool
WatchInterval time.Duration
ExpandEnvVars bool
ExpandSecrets bool
RequireFile bool
BackupEnabled bool
BackupDir string
ValidationRules []configcore.ValidationRule
SecretKeys []string
Logger logger.Logger
ErrorHandler shared.ErrorHandler
}
FileSourceOptions contains options for file sources.
type K8sSource ¶
type K8sSource struct {
// contains filtered or unexported fields
}
K8sSource represents a Kubernetes ConfigMap/Secret configuration source.
func (*K8sSource) IsAvailable ¶
IsAvailable checks if the source is available.
func (*K8sSource) IsWatchable ¶
IsWatchable returns true if Kubernetes watching is enabled.
func (*K8sSource) SupportsSecrets ¶
SupportsSecrets returns true (Kubernetes can store secrets).
type K8sSourceConfig ¶
type K8sSourceConfig struct {
Namespace string `json:"namespace" yaml:"namespace"`
ConfigMapNames []string `json:"configmap_names" yaml:"configmap_names"`
SecretNames []string `json:"secret_names" yaml:"secret_names"`
Priority int `json:"priority" yaml:"priority"`
WatchEnabled bool `json:"watch_enabled" yaml:"watch_enabled"`
KubeConfig string `json:"kubeconfig" yaml:"kubeconfig"`
InCluster bool `json:"in_cluster" yaml:"in_cluster"`
LabelSelector string `json:"label_selector" yaml:"label_selector"`
FieldSelector string `json:"field_selector" yaml:"field_selector"`
RetryCount int `json:"retry_count" yaml:"retry_count"`
RetryDelay time.Duration `json:"retry_delay" yaml:"retry_delay"`
}
K8sSourceConfig contains configuration for creating Kubernetes sources.
type K8sSourceFactory ¶
type K8sSourceFactory struct {
// contains filtered or unexported fields
}
K8sSourceFactory creates Kubernetes configuration sources.
func NewK8sSourceFactory ¶
func NewK8sSourceFactory(logger logger.Logger, errorHandler shared.ErrorHandler) *K8sSourceFactory
NewK8sSourceFactory creates a new Kubernetes source factory.
func (*K8sSourceFactory) CreateFromConfig ¶
func (factory *K8sSourceFactory) CreateFromConfig(config K8sSourceConfig) (configcore.ConfigSource, error)
CreateFromConfig creates a Kubernetes source from configuration.
func (*K8sSourceFactory) CreateWithDefaults ¶
func (factory *K8sSourceFactory) CreateWithDefaults(namespace string) (configcore.ConfigSource, error)
CreateWithDefaults creates a Kubernetes source with default settings.
type K8sSourceOptions ¶
type K8sSourceOptions struct {
Name string
Namespace string
ConfigMapNames []string
SecretNames []string
Priority int
WatchEnabled bool
KubeConfig string
InCluster bool
LabelSelector string
FieldSelector string
RetryCount int
RetryDelay time.Duration
Logger logger.Logger
ErrorHandler shared.ErrorHandler
}
K8sSourceOptions contains options for Kubernetes configuration sources.
type KeyTransformFunc ¶
KeyTransformFunc transforms environment variable keys.
type ValueTransformFunc ¶
ValueTransformFunc transforms environment variable values.