config

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeverityError   = errors.SeverityError
	SeverityWarning = errors.SeverityWarning
	SeverityInfo    = errors.SeverityInfo
)
View Source
const ConfigKey = shared.ConfigKey

ConfigKey is the service key for configuration manager

View Source
const ManagerKey = ConfigKey

Variables

View Source
var (
	ErrConfigError     = errors.ErrConfigError
	ErrLifecycleError  = errors.ErrLifecycleError
	ErrValidationError = errors.ErrValidationError
)

Functions

func AllowEmpty

func AllowEmpty() configcore.GetOption

AllowEmpty allows empty values

func ExpandSecretReferences

func ExpandSecretReferences(ctx context.Context, data map[string]interface{}, secretsManager SecretsManager) (map[string]interface{}, error)

ExpandSecretReferences expands secret references in configuration

func ExtractSecretKey

func ExtractSecretKey(reference string) string

ExtractSecretKey extracts the secret key from a reference

func IsSecretReference

func IsSecretReference(value string) bool

IsSecretReference checks if a value is a secret reference

func WithCacheKey

func WithCacheKey(key string) configcore.GetOption

WithCacheKey sets a custom cache key

func WithDefault

func WithDefault(value interface{}) configcore.GetOption

WithDefault sets a default value

func WithOnMissing

func WithOnMissing(fn func(string) interface{}) configcore.GetOption

WithOnMissing sets a callback for missing keys

func WithRequired

func WithRequired() configcore.GetOption

WithRequired marks the key as required

func WithTransform

func WithTransform(fn func(interface{}) interface{}) configcore.GetOption

WithTransform adds a transformation function

func WithValidator

func WithValidator(fn func(interface{}) error) configcore.GetOption

WithValidator adds a validation function

Types

type CachedSecret

type CachedSecret struct {
	Value     string         `json:"value"`
	Metadata  SecretMetadata `json:"metadata"`
	ExpiresAt time.Time      `json:"expires_at"`
	Encrypted bool           `json:"encrypted"`
}

CachedSecret represents a cached secret

type ChangeDetector

type ChangeDetector interface {
	DetectChanges(old, new map[string]interface{}) []ConfigChange
	CalculateChecksum(data map[string]interface{}) string
}

ChangeDetector detects changes in configuration data

type ChangeType

type ChangeType = core.ChangeType

ChangeType represents the type of configuration change

const (
	ChangeTypeSet    ChangeType = core.ChangeTypeSet
	ChangeTypeUpdate ChangeType = core.ChangeTypeUpdate
	ChangeTypeDelete ChangeType = core.ChangeTypeDelete
	ChangeTypeReload ChangeType = core.ChangeTypeReload
)

type ConfigChange

type ConfigChange = core.ConfigChange

ConfigChange represents a configuration change event

type ConfigManager

type ConfigManager = core.ConfigManager

ConfigManager interface (matches v2.ConfigManagerInterface)

func NewManager

func NewManager(config ManagerConfig) ConfigManager

NewManager creates a new enhanced configuration manager

func NewTestConfigManager

func NewTestConfigManager() ConfigManager

NewTestConfigManager creates a new test configuration manager

func NewTestConfigManagerWithData

func NewTestConfigManagerWithData(data map[string]interface{}) ConfigManager

NewTestConfigManagerWithData creates a test config manager with initial data

type ConfigSource

type ConfigSource = core.ConfigSource

ConfigSource represents a source of configuration data

type ConfigSourceFactory

type ConfigSourceFactory = core.ConfigSourceFactory

ConfigSourceFactory creates configuration sources

type ConfigSourceOptions

type ConfigSourceOptions = core.ConfigSourceOptions

ConfigSourceOptions contains options for creating a configuration source

type ConstraintRule

type ConstraintRule interface {
	Name() string
	Description() string
	Validate(key string, value interface{}, config map[string]interface{}) error
	AppliesTo(key string) bool
}

ConstraintRule defines a constraint that must be satisfied

type DebounceWatcher

type DebounceWatcher struct {
	*Watcher
	// contains filtered or unexported fields
}

DebounceWatcher wraps another watcher with debouncing functionality

func NewDebounceWatcher

func NewDebounceWatcher(config WatcherConfig, debounceTime time.Duration) *DebounceWatcher

NewDebounceWatcher creates a watcher with debouncing

func (*DebounceWatcher) WatchSource

func (dw *DebounceWatcher) WatchSource(ctx context.Context, source ConfigSource, callback WatchCallback) error

WatchSource starts watching with debouncing

type DefaultChangeDetector

type DefaultChangeDetector struct{}

DefaultChangeDetector is a simple implementation of ChangeDetector

func (*DefaultChangeDetector) CalculateChecksum

func (d *DefaultChangeDetector) CalculateChecksum(data map[string]interface{}) string

func (*DefaultChangeDetector) DetectChanges

func (d *DefaultChangeDetector) DetectChanges(old, new map[string]interface{}) []ConfigChange

type DurationRule

type DurationRule struct{}

func (*DurationRule) AppliesTo

func (r *DurationRule) AppliesTo(key string) bool

func (*DurationRule) Name

func (r *DurationRule) Name() string

func (*DurationRule) Validate

func (r *DurationRule) Validate(key string, value interface{}) error

type EmailRule

type EmailRule struct{}

func (*EmailRule) AppliesTo

func (r *EmailRule) AppliesTo(key string) bool

func (*EmailRule) Name

func (r *EmailRule) Name() string

func (*EmailRule) Validate

func (r *EmailRule) Validate(key string, value interface{}) error

type EnvironmentSecretProvider

type EnvironmentSecretProvider struct {
	// contains filtered or unexported fields
}

EnvironmentSecretProvider provides secrets from environment variables

func (*EnvironmentSecretProvider) Close

func (*EnvironmentSecretProvider) DeleteSecret

func (esp *EnvironmentSecretProvider) DeleteSecret(ctx context.Context, key string) error

func (*EnvironmentSecretProvider) GetSecret

func (esp *EnvironmentSecretProvider) GetSecret(ctx context.Context, key string) (string, error)

func (*EnvironmentSecretProvider) HealthCheck

func (esp *EnvironmentSecretProvider) HealthCheck(ctx context.Context) error

func (*EnvironmentSecretProvider) Initialize

func (esp *EnvironmentSecretProvider) Initialize(ctx context.Context, config map[string]interface{}) error

func (*EnvironmentSecretProvider) ListSecrets

func (esp *EnvironmentSecretProvider) ListSecrets(ctx context.Context) ([]string, error)

func (*EnvironmentSecretProvider) Name

func (esp *EnvironmentSecretProvider) Name() string

func (*EnvironmentSecretProvider) SetSecret

func (esp *EnvironmentSecretProvider) SetSecret(ctx context.Context, key, value string) error

func (*EnvironmentSecretProvider) SupportsCaching

func (esp *EnvironmentSecretProvider) SupportsCaching() bool

func (*EnvironmentSecretProvider) SupportsRotation

func (esp *EnvironmentSecretProvider) SupportsRotation() bool

type FileSecretProvider

type FileSecretProvider struct {
	// contains filtered or unexported fields
}

FileSecretProvider provides secrets from files

func (*FileSecretProvider) Close

func (fsp *FileSecretProvider) Close(ctx context.Context) error

func (*FileSecretProvider) DeleteSecret

func (fsp *FileSecretProvider) DeleteSecret(ctx context.Context, key string) error

func (*FileSecretProvider) GetSecret

func (fsp *FileSecretProvider) GetSecret(ctx context.Context, key string) (string, error)

func (*FileSecretProvider) HealthCheck

func (fsp *FileSecretProvider) HealthCheck(ctx context.Context) error

func (*FileSecretProvider) Initialize

func (fsp *FileSecretProvider) Initialize(ctx context.Context, config map[string]interface{}) error

func (*FileSecretProvider) ListSecrets

func (fsp *FileSecretProvider) ListSecrets(ctx context.Context) ([]string, error)

func (*FileSecretProvider) Name

func (fsp *FileSecretProvider) Name() string

func (*FileSecretProvider) SetSecret

func (fsp *FileSecretProvider) SetSecret(ctx context.Context, key, value string) error

func (*FileSecretProvider) SupportsCaching

func (fsp *FileSecretProvider) SupportsCaching() bool

func (*FileSecretProvider) SupportsRotation

func (fsp *FileSecretProvider) SupportsRotation() bool

type FileWatcher

type FileWatcher interface {
	Watch(path string, callback func(string)) error
	Stop() error
}

FileWatcher represents a file system watcher

type ForgeError

type ForgeError = errors.ForgeError

Re-export error types and constructors for backward compatibility

type HealthCall

type HealthCall struct {
	Timestamp time.Time
	Error     error
	Healthy   bool
}

HealthCall represents a tracked health check

type LifecycleCall

type LifecycleCall struct {
	Timestamp time.Time
	Error     error
}

LifecycleCall represents a tracked lifecycle operation

type ListCall

type ListCall struct {
	Result    []string
	Timestamp time.Time
	Error     error
}

ListCall represents a tracked list operation

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager implements an enhanced configuration manager that extends ConfigManager

func (*Manager) AllKeys

func (m *Manager) AllKeys() []string

AllKeys is an alias for GetKeys

func (*Manager) AllSettings

func (m *Manager) AllSettings() map[string]interface{}

AllSettings is an alias for GetAllSettings

func (*Manager) Bind

func (m *Manager) Bind(key string, target interface{}) error

Bind binds configuration to a struct

func (*Manager) BindWithDefault

func (m *Manager) BindWithDefault(key string, target interface{}, defaultValue interface{}) error

BindWithDefault binds with a default value

func (*Manager) BindWithOptions

func (m *Manager) BindWithOptions(key string, target interface{}, options configcore.BindOptions) error

BindWithOptions binds with flexible options

func (*Manager) Clone

func (m *Manager) Clone() ConfigManager

Clone creates a deep copy

func (*Manager) ConfigFileUsed

func (m *Manager) ConfigFileUsed() string

ConfigFileUsed returns the config file path

func (*Manager) ExpandEnvVars

func (m *Manager) ExpandEnvVars() error

ExpandEnvVars expands environment variables

func (*Manager) Get

func (m *Manager) Get(key string) interface{}

Get returns a configuration value

func (*Manager) GetAllSettings

func (m *Manager) GetAllSettings() map[string]interface{}

GetAllSettings returns all settings

func (*Manager) GetBool

func (m *Manager) GetBool(key string, defaultValue ...bool) bool

GetBool returns a bool value with optional default

func (*Manager) GetBoolSlice

func (m *Manager) GetBoolSlice(key string, defaultValue ...[]bool) []bool

GetBoolSlice returns a bool slice with optional default

func (*Manager) GetBoolWithOptions

func (m *Manager) GetBoolWithOptions(key string, opts ...configcore.GetOption) (bool, error)

GetBoolWithOptions returns a bool with advanced options

func (*Manager) GetBytesSize

func (m *Manager) GetBytesSize(key string, defaultValue ...uint64) uint64

GetBytesSize is an alias for GetSizeInBytes

func (*Manager) GetDuration

func (m *Manager) GetDuration(key string, defaultValue ...time.Duration) time.Duration

GetDuration returns a duration value with optional default

func (*Manager) GetDurationWithOptions

func (m *Manager) GetDurationWithOptions(key string, opts ...configcore.GetOption) (time.Duration, error)

GetDurationWithOptions returns a duration with advanced options

func (*Manager) GetFloat32

func (m *Manager) GetFloat32(key string, defaultValue ...float32) float32

GetFloat32 returns a float32 value with optional default

func (*Manager) GetFloat64

func (m *Manager) GetFloat64(key string, defaultValue ...float64) float64

GetFloat64 returns a float64 value with optional default

func (*Manager) GetFloat64Slice

func (m *Manager) GetFloat64Slice(key string, defaultValue ...[]float64) []float64

GetFloat64Slice returns a float64 slice with optional default

func (*Manager) GetInt

func (m *Manager) GetInt(key string, defaultValue ...int) int

GetInt returns an int value with optional default

func (*Manager) GetInt16

func (m *Manager) GetInt16(key string, defaultValue ...int16) int16

GetInt16 returns an int16 value with optional default

func (*Manager) GetInt32

func (m *Manager) GetInt32(key string, defaultValue ...int32) int32

GetInt32 returns an int32 value with optional default

func (*Manager) GetInt64

func (m *Manager) GetInt64(key string, defaultValue ...int64) int64

GetInt64 returns an int64 value with optional default

func (*Manager) GetInt64Slice

func (m *Manager) GetInt64Slice(key string, defaultValue ...[]int64) []int64

GetInt64Slice returns an int64 slice with optional default

func (*Manager) GetInt8

func (m *Manager) GetInt8(key string, defaultValue ...int8) int8

GetInt8 returns an int8 value with optional default

func (*Manager) GetIntSlice

func (m *Manager) GetIntSlice(key string, defaultValue ...[]int) []int

GetIntSlice returns an int slice with optional default

func (*Manager) GetIntWithOptions

func (m *Manager) GetIntWithOptions(key string, opts ...configcore.GetOption) (int, error)

GetIntWithOptions returns an int with advanced options

func (*Manager) GetKeys

func (m *Manager) GetKeys() []string

GetKeys returns all configuration keys

func (*Manager) GetSection

func (m *Manager) GetSection(key string) map[string]interface{}

GetSection returns a configuration section

func (*Manager) GetSizeInBytes

func (m *Manager) GetSizeInBytes(key string, defaultValue ...uint64) uint64

GetSizeInBytes returns size in bytes with optional default

func (*Manager) GetSourceMetadata

func (m *Manager) GetSourceMetadata() map[string]*SourceMetadata

GetSourceMetadata returns metadata for all sources

func (*Manager) GetString

func (m *Manager) GetString(key string, defaultValue ...string) string

GetString returns a string value with optional default

func (*Manager) GetStringMap

func (m *Manager) GetStringMap(key string, defaultValue ...map[string]string) map[string]string

GetStringMap returns a string map with optional default

func (*Manager) GetStringMapString

func (m *Manager) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string

GetStringMapString is an alias for GetStringMap

func (*Manager) GetStringMapStringSlice

func (m *Manager) GetStringMapStringSlice(key string, defaultValue ...map[string][]string) map[string][]string

GetStringMapStringSlice returns a map of string slices with optional default

func (*Manager) GetStringSlice

func (m *Manager) GetStringSlice(key string, defaultValue ...[]string) []string

GetStringSlice returns a string slice with optional default

func (*Manager) GetStringWithOptions

func (m *Manager) GetStringWithOptions(key string, opts ...configcore.GetOption) (string, error)

GetStringWithOptions returns a string with advanced options

func (*Manager) GetTime

func (m *Manager) GetTime(key string, defaultValue ...time.Time) time.Time

GetTime returns a time value with optional default

func (*Manager) GetUint

func (m *Manager) GetUint(key string, defaultValue ...uint) uint

GetUint returns a uint value with optional default

func (*Manager) GetUint16

func (m *Manager) GetUint16(key string, defaultValue ...uint16) uint16

GetUint16 returns a uint16 value with optional default

func (*Manager) GetUint32

func (m *Manager) GetUint32(key string, defaultValue ...uint32) uint32

GetUint32 returns a uint32 value with optional default

func (*Manager) GetUint64

func (m *Manager) GetUint64(key string, defaultValue ...uint64) uint64

GetUint64 returns a uint64 value with optional default

func (*Manager) GetUint8

func (m *Manager) GetUint8(key string, defaultValue ...uint8) uint8

GetUint8 returns a uint8 value with optional default

func (*Manager) GetWithOptions

func (m *Manager) GetWithOptions(key string, opts ...configcore.GetOption) (interface{}, error)

GetWithOptions returns a value with advanced options

func (*Manager) HasKey

func (m *Manager) HasKey(key string) bool

HasKey checks if a key exists

func (*Manager) InConfig

func (m *Manager) InConfig(key string) bool

InConfig is an alias for HasKey

func (*Manager) IsSet

func (m *Manager) IsSet(key string) bool

IsSet checks if a key is set and not empty

func (*Manager) LoadFrom

func (m *Manager) LoadFrom(sources ...ConfigSource) error

LoadFrom loads configuration from multiple sources

func (*Manager) MergeWith

func (m *Manager) MergeWith(other ConfigManager) error

MergeWith merges another config manager

func (*Manager) Name

func (m *Manager) Name() string

func (*Manager) OnConfigChange

func (m *Manager) OnConfigChange(callback func(ConfigChange))

OnConfigChange is an alias for WatchChanges

func (*Manager) ReadInConfig

func (m *Manager) ReadInConfig() error

ReadInConfig reads configuration

func (*Manager) Reload

func (m *Manager) Reload() error

Reload forces a reload of all configuration sources

func (*Manager) ReloadContext

func (m *Manager) ReloadContext(ctx context.Context) error

ReloadContext forces a reload with context

func (*Manager) Reset

func (m *Manager) Reset()

Reset clears all configuration

func (*Manager) SafeGet

func (m *Manager) SafeGet(key string, expectedType reflect.Type) (interface{}, error)

SafeGet returns a value with type checking

func (*Manager) SecretsManager

func (m *Manager) SecretsManager() SecretsManager

func (*Manager) Set

func (m *Manager) Set(key string, value interface{})

Set sets a configuration value

func (*Manager) SetConfigFile

func (m *Manager) SetConfigFile(filePath string) error

SetConfigFile sets the configuration file

func (*Manager) SetConfigType

func (m *Manager) SetConfigType(configType string)

SetConfigType sets the configuration type

func (*Manager) Size

func (m *Manager) Size() int

Size returns the number of keys

func (*Manager) Stop

func (m *Manager) Stop() error

Stop stops the configuration manager

func (*Manager) Sub

func (m *Manager) Sub(key string) ConfigManager

Sub returns a sub-configuration manager

func (*Manager) Unmarshal

func (m *Manager) Unmarshal(rawVal interface{}) error

Unmarshal unmarshals entire configuration

func (*Manager) UnmarshalKey

func (m *Manager) UnmarshalKey(key string, rawVal interface{}) error

UnmarshalKey is an alias for Bind

func (*Manager) Validate

func (m *Manager) Validate() error

Validate validates the current configuration

func (*Manager) Watch

func (m *Manager) Watch(ctx context.Context) error

Watch starts watching for configuration changes

func (*Manager) WatchChanges

func (m *Manager) WatchChanges(callback func(ConfigChange))

WatchChanges registers a callback for all changes

func (*Manager) WatchConfig

func (m *Manager) WatchConfig() error

WatchConfig is an alias for Watch

func (*Manager) WatchWithCallback

func (m *Manager) WatchWithCallback(key string, callback func(string, interface{}))

WatchWithCallback registers a callback for key changes

type ManagerConfig

type ManagerConfig struct {
	DefaultSources  []SourceConfig      `yaml:"default_sources" json:"default_sources"`
	WatchInterval   time.Duration       `yaml:"watch_interval" json:"watch_interval"`
	ValidationMode  ValidationMode      `yaml:"validation_mode" json:"validation_mode"`
	SecretsEnabled  bool                `yaml:"secrets_enabled" json:"secrets_enabled"`
	CacheEnabled    bool                `yaml:"cache_enabled" json:"cache_enabled"`
	ReloadOnChange  bool                `yaml:"reload_on_change" json:"reload_on_change"`
	ErrorRetryCount int                 `yaml:"error_retry_count" json:"error_retry_count"`
	ErrorRetryDelay time.Duration       `yaml:"error_retry_delay" json:"error_retry_delay"`
	MetricsEnabled  bool                `yaml:"metrics_enabled" json:"metrics_enabled"`
	Logger          logger.Logger       `yaml:"-" json:"-"`
	Metrics         shared.Metrics      `yaml:"-" json:"-"`
	ErrorHandler    shared.ErrorHandler `yaml:"-" json:"-"`
}

ManagerConfig contains configuration for the config manager

type MemorySecretProvider

type MemorySecretProvider struct {
	// contains filtered or unexported fields
}

MemorySecretProvider provides secrets from memory (for testing)

func (*MemorySecretProvider) Close

func (msp *MemorySecretProvider) Close(ctx context.Context) error

func (*MemorySecretProvider) DeleteSecret

func (msp *MemorySecretProvider) DeleteSecret(ctx context.Context, key string) error

func (*MemorySecretProvider) GetSecret

func (msp *MemorySecretProvider) GetSecret(ctx context.Context, key string) (string, error)

func (*MemorySecretProvider) HealthCheck

func (msp *MemorySecretProvider) HealthCheck(ctx context.Context) error

func (*MemorySecretProvider) Initialize

func (msp *MemorySecretProvider) Initialize(ctx context.Context, config map[string]interface{}) error

func (*MemorySecretProvider) ListSecrets

func (msp *MemorySecretProvider) ListSecrets(ctx context.Context) ([]string, error)

func (*MemorySecretProvider) Name

func (msp *MemorySecretProvider) Name() string

func (*MemorySecretProvider) SetSecret

func (msp *MemorySecretProvider) SetSecret(ctx context.Context, key, value string) error

func (*MemorySecretProvider) SupportsCaching

func (msp *MemorySecretProvider) SupportsCaching() bool

func (*MemorySecretProvider) SupportsRotation

func (msp *MemorySecretProvider) SupportsRotation() bool

type MockSecretsBuilder

type MockSecretsBuilder struct {
	// contains filtered or unexported fields
}

MockSecretsBuilder provides fluent interface for building test scenarios

func NewMockSecretsBuilder

func NewMockSecretsBuilder() *MockSecretsBuilder

NewMockSecretsBuilder creates a new builder

func (*MockSecretsBuilder) Build

Build returns the configured mock

func (*MockSecretsBuilder) WithGetError

func (b *MockSecretsBuilder) WithGetError(err error) *MockSecretsBuilder

WithGetError configures GetSecret error

func (*MockSecretsBuilder) WithLatency

func (b *MockSecretsBuilder) WithLatency(latency time.Duration) *MockSecretsBuilder

WithLatency configures latency simulation

func (*MockSecretsBuilder) WithProvider

func (b *MockSecretsBuilder) WithProvider(name string, provider SecretProvider) *MockSecretsBuilder

WithProvider adds a provider

func (*MockSecretsBuilder) WithSecret

func (b *MockSecretsBuilder) WithSecret(key, value string) *MockSecretsBuilder

WithSecret adds a secret to the mock

func (*MockSecretsBuilder) WithSecrets

func (b *MockSecretsBuilder) WithSecrets(secrets map[string]string) *MockSecretsBuilder

WithSecrets adds multiple secrets

func (*MockSecretsBuilder) WithSetError

func (b *MockSecretsBuilder) WithSetError(err error) *MockSecretsBuilder

WithSetError configures SetSecret error

func (*MockSecretsBuilder) WithStarted

func (b *MockSecretsBuilder) WithStarted(started bool) *MockSecretsBuilder

WithStarted sets the started state

type MockSecretsManager

type MockSecretsManager struct {
	// contains filtered or unexported fields
}

MockSecretsManager is a comprehensive mock implementation of SecretsManager optimized for testing with call tracking, assertions, and behavior simulation

func NewMockSecretsManager

func NewMockSecretsManager() *MockSecretsManager

NewMockSecretsManager creates a new mock secrets manager with default settings

func NewMockSecretsManagerWithSecrets

func NewMockSecretsManagerWithSecrets(secrets map[string]string) *MockSecretsManager

NewMockSecretsManagerWithSecrets creates a mock with initial secrets

func (*MockSecretsManager) ClearErrors

func (m *MockSecretsManager) ClearErrors()

ClearErrors clears all configured errors

func (*MockSecretsManager) DeleteCallCount

func (m *MockSecretsManager) DeleteCallCount() int

DeleteCallCount returns the number of DeleteSecret calls

func (*MockSecretsManager) DeleteCalls

func (m *MockSecretsManager) DeleteCalls() []SecretCall

DeleteCalls returns all DeleteSecret calls

func (*MockSecretsManager) DeleteSecret

func (m *MockSecretsManager) DeleteSecret(ctx context.Context, key string) error

DeleteSecret removes a secret

func (*MockSecretsManager) ErrorCount

func (m *MockSecretsManager) ErrorCount() int64

ErrorCount returns the total number of errors

func (*MockSecretsManager) GetCallCount

func (m *MockSecretsManager) GetCallCount() int

GetCallCount returns the number of GetSecret calls

func (*MockSecretsManager) GetCalls

func (m *MockSecretsManager) GetCalls() []SecretCall

GetCalls returns all GetSecret calls

func (*MockSecretsManager) GetProvider

func (m *MockSecretsManager) GetProvider(name string) (SecretProvider, error)

GetProvider returns a secrets provider by name

func (*MockSecretsManager) GetSecret

func (m *MockSecretsManager) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret by key

func (*MockSecretsManager) GetStats

func (m *MockSecretsManager) GetStats() MockStats

GetStats returns usage statistics

func (*MockSecretsManager) HealthCallCount

func (m *MockSecretsManager) HealthCallCount() int

HealthCallCount returns the number of HealthCheck calls

func (*MockSecretsManager) HealthCalls

func (m *MockSecretsManager) HealthCalls() []HealthCall

HealthCalls returns all HealthCheck calls

func (*MockSecretsManager) HealthCheck

func (m *MockSecretsManager) HealthCheck(ctx context.Context) error

HealthCheck performs a health check

func (*MockSecretsManager) IsStarted

func (m *MockSecretsManager) IsStarted() bool

IsStarted returns whether the manager is started

func (*MockSecretsManager) LastAccessed

func (m *MockSecretsManager) LastAccessed() time.Time

LastAccessed returns the timestamp of the last operation

func (*MockSecretsManager) ListCallCount

func (m *MockSecretsManager) ListCallCount() int

ListCallCount returns the number of ListSecrets calls

func (*MockSecretsManager) ListCalls

func (m *MockSecretsManager) ListCalls() []ListCall

ListCalls returns all ListSecrets calls

func (*MockSecretsManager) ListSecrets

func (m *MockSecretsManager) ListSecrets(ctx context.Context) ([]string, error)

ListSecrets returns all secret keys

func (*MockSecretsManager) PrintStats

func (m *MockSecretsManager) PrintStats()

PrintStats prints statistics for debugging

func (*MockSecretsManager) ProviderCount

func (m *MockSecretsManager) ProviderCount() int

ProviderCount returns the number of registered providers

func (*MockSecretsManager) RefreshCallCount

func (m *MockSecretsManager) RefreshCallCount() int

RefreshCallCount returns the number of RefreshSecrets calls

func (*MockSecretsManager) RefreshCalls

func (m *MockSecretsManager) RefreshCalls() []RefreshCall

RefreshCalls returns all RefreshSecrets calls

func (*MockSecretsManager) RefreshSecrets

func (m *MockSecretsManager) RefreshSecrets(ctx context.Context) error

RefreshSecrets refreshes all cached secrets

func (*MockSecretsManager) RegisterProvider

func (m *MockSecretsManager) RegisterProvider(name string, provider SecretProvider) error

RegisterProvider registers a secrets provider

func (*MockSecretsManager) Reset

func (m *MockSecretsManager) Reset()

Reset resets the mock to its initial state

func (*MockSecretsManager) ResetCallTracking

func (m *MockSecretsManager) ResetCallTracking()

ResetCallTracking resets only the call tracking (keeps secrets and state)

func (*MockSecretsManager) RotateCallCount

func (m *MockSecretsManager) RotateCallCount() int

RotateCallCount returns the number of RotateSecret calls

func (*MockSecretsManager) RotateCalls

func (m *MockSecretsManager) RotateCalls() []RotateCall

RotateCalls returns all RotateSecret calls

func (*MockSecretsManager) RotateSecret

func (m *MockSecretsManager) RotateSecret(ctx context.Context, key, newValue string) error

RotateSecret rotates a secret with a new value

func (*MockSecretsManager) SecretCount

func (m *MockSecretsManager) SecretCount() int

SecretCount returns the number of secrets stored

func (*MockSecretsManager) SetCallCount

func (m *MockSecretsManager) SetCallCount() int

SetCallCount returns the number of SetSecret calls

func (*MockSecretsManager) SetCalls

func (m *MockSecretsManager) SetCalls() []SecretCall

SetCalls returns all SetSecret calls

func (*MockSecretsManager) SetDeleteError

func (m *MockSecretsManager) SetDeleteError(err error)

SetDeleteError configures DeleteSecret to return an error

func (*MockSecretsManager) SetGetError

func (m *MockSecretsManager) SetGetError(err error)

SetGetError configures GetSecret to return an error

func (*MockSecretsManager) SetHealthError

func (m *MockSecretsManager) SetHealthError(err error)

SetHealthError configures HealthCheck to return an error

func (*MockSecretsManager) SetLatencySimulation

func (m *MockSecretsManager) SetLatencySimulation(latency time.Duration)

SetLatencySimulation configures artificial latency for all operations

func (*MockSecretsManager) SetListError

func (m *MockSecretsManager) SetListError(err error)

SetListError configures ListSecrets to return an error

func (*MockSecretsManager) SetRefreshError

func (m *MockSecretsManager) SetRefreshError(err error)

SetRefreshError configures RefreshSecrets to return an error

func (*MockSecretsManager) SetRotateError

func (m *MockSecretsManager) SetRotateError(err error)

SetRotateError configures RotateSecret to return an error

func (*MockSecretsManager) SetSecret

func (m *MockSecretsManager) SetSecret(ctx context.Context, key, value string) error

SetSecret stores a secret

func (*MockSecretsManager) SetSetError

func (m *MockSecretsManager) SetSetError(err error)

SetSetError configures SetSecret to return an error

func (*MockSecretsManager) SetStartError

func (m *MockSecretsManager) SetStartError(err error)

SetStartError configures Start to return an error

func (*MockSecretsManager) SetStopError

func (m *MockSecretsManager) SetStopError(err error)

SetStopError configures Stop to return an error

func (*MockSecretsManager) Start

func (m *MockSecretsManager) Start(ctx context.Context) error

Start starts the secrets manager

func (*MockSecretsManager) StartCallCount

func (m *MockSecretsManager) StartCallCount() int

StartCallCount returns the number of Start calls

func (*MockSecretsManager) StartCalls

func (m *MockSecretsManager) StartCalls() []LifecycleCall

StartCalls returns all Start calls

func (*MockSecretsManager) Stop

func (m *MockSecretsManager) Stop(ctx context.Context) error

Stop stops the secrets manager

func (*MockSecretsManager) StopCallCount

func (m *MockSecretsManager) StopCallCount() int

StopCallCount returns the number of Stop calls

func (*MockSecretsManager) StopCalls

func (m *MockSecretsManager) StopCalls() []LifecycleCall

StopCalls returns all Stop calls

func (*MockSecretsManager) TotalCallCount

func (m *MockSecretsManager) TotalCallCount() int64

TotalCallCount returns the total number of calls

func (*MockSecretsManager) WasDeleteCalledWith

func (m *MockSecretsManager) WasDeleteCalledWith(key string) bool

WasDeleteCalledWith checks if DeleteSecret was called with a specific key

func (*MockSecretsManager) WasGetCalledWith

func (m *MockSecretsManager) WasGetCalledWith(key string) bool

WasGetCalledWith checks if GetSecret was called with a specific key

func (*MockSecretsManager) WasRotateCalledWith

func (m *MockSecretsManager) WasRotateCalledWith(key string) bool

WasRotateCalledWith checks if RotateSecret was called with a specific key

func (*MockSecretsManager) WasSetCalledWith

func (m *MockSecretsManager) WasSetCalledWith(key, value string) bool

WasSetCalledWith checks if SetSecret was called with a specific key and value

type MockStats

type MockStats struct {
	SecretCount   int
	ProviderCount int
	TotalCalls    int64
	ErrorCount    int64
	Started       bool
	LastAccessed  time.Time

	GetCalls     int
	SetCalls     int
	DeleteCalls  int
	ListCalls    int
	RotateCalls  int
	RefreshCalls int
	StartCalls   int
	StopCalls    int
	HealthCalls  int
}

Stats contains statistics about the mock's usage

type PortRule

type PortRule struct{}

func (*PortRule) AppliesTo

func (r *PortRule) AppliesTo(key string) bool

func (*PortRule) Name

func (r *PortRule) Name() string

func (*PortRule) Validate

func (r *PortRule) Validate(key string, value interface{}) error

type PropertySchema

type PropertySchema struct {
	Type        PropertyType              `json:"type"`
	Required    bool                      `json:"required"`
	Default     interface{}               `json:"default,omitempty"`
	Description string                    `json:"description,omitempty"`
	Format      string                    `json:"format,omitempty"`
	Pattern     string                    `json:"pattern,omitempty"`
	Enum        []interface{}             `json:"enum,omitempty"`
	Minimum     *float64                  `json:"minimum,omitempty"`
	Maximum     *float64                  `json:"maximum,omitempty"`
	MinLength   *int                      `json:"min_length,omitempty"`
	MaxLength   *int                      `json:"max_length,omitempty"`
	Items       *PropertySchema           `json:"items,omitempty"`
	Properties  map[string]PropertySchema `json:"properties,omitempty"`
	Constraints []ConstraintRule          `json:"constraints,omitempty"`
}

PropertySchema defines validation for a specific property

type PropertyType

type PropertyType string

PropertyType represents the type of a configuration property

const (
	PropertyTypeString  PropertyType = "string"
	PropertyTypeInteger PropertyType = "integer"
	PropertyTypeNumber  PropertyType = "number"
	PropertyTypeBoolean PropertyType = "boolean"
	PropertyTypeArray   PropertyType = "array"
	PropertyTypeObject  PropertyType = "object"
	PropertyTypeAny     PropertyType = "any"
)

type ProviderConfig

type ProviderConfig struct {
	Type       string                 `yaml:"type" json:"type"`
	Priority   int                    `yaml:"priority" json:"priority"`
	Properties map[string]interface{} `yaml:"properties" json:"properties"`
	Enabled    bool                   `yaml:"enabled" json:"enabled"`
}

ProviderConfig contains configuration for a secret provider

type RefreshCall

type RefreshCall struct {
	Timestamp time.Time
	Error     error
}

RefreshCall represents a tracked refresh operation

type RotateCall

type RotateCall struct {
	Key       string
	OldValue  string
	NewValue  string
	Timestamp time.Time
	Error     error
}

RotateCall represents a tracked rotate operation

type SecretCall

type SecretCall struct {
	Key       string
	Value     string
	Timestamp time.Time
	Error     error
}

SecretCall represents a tracked secret operation call

type SecretEncryptor

type SecretEncryptor struct {
	// contains filtered or unexported fields
}

SecretEncryptor handles encryption and decryption of secrets

func NewSecretEncryptor

func NewSecretEncryptor(keyStr string) *SecretEncryptor

NewSecretEncryptor creates a new secret encryptor

func (*SecretEncryptor) Decrypt

func (se *SecretEncryptor) Decrypt(ciphertext string) (string, error)

Decrypt decrypts a secret value

func (*SecretEncryptor) Encrypt

func (se *SecretEncryptor) Encrypt(plaintext string) (string, error)

Encrypt encrypts a secret value

type SecretGenerator

type SecretGenerator interface {
	GenerateSecret(ctx context.Context, key string, metadata SecretMetadata) (string, error)
	ValidateSecret(ctx context.Context, value string) error
}

SecretGenerator generates new secret values

type SecretMetadata

type SecretMetadata struct {
	Key          string                 `json:"key"`
	Provider     string                 `json:"provider"`
	Created      time.Time              `json:"created"`
	LastAccessed time.Time              `json:"last_accessed"`
	LastRotated  time.Time              `json:"last_rotated,omitempty"`
	AccessCount  int64                  `json:"access_count"`
	Tags         map[string]string      `json:"tags,omitempty"`
	Encrypted    bool                   `json:"encrypted"`
	TTL          time.Duration          `json:"ttl,omitempty"`
	Properties   map[string]interface{} `json:"properties,omitempty"`
}

SecretMetadata contains metadata about a secret

type SecretProvider

type SecretProvider = configscore.SecretProvider

SecretProvider defines an interface for different secret backends

type SecretRotationPolicy

type SecretRotationPolicy struct {
	Enabled    bool              `json:"enabled"`
	Interval   time.Duration     `json:"interval"`
	MaxAge     time.Duration     `json:"max_age"`
	Generator  SecretGenerator   `json:"-"`
	Validators []SecretValidator `json:"-"`
	NotifyOn   []string          `json:"notify_on"`
}

SecretRotationPolicy defines how secrets should be rotated

type SecretValidator

type SecretValidator interface {
	ValidateSecret(ctx context.Context, key, value string) error
	GetValidationRules() []string
}

SecretValidator validates secret values

type SecretsConfig

type SecretsConfig struct {
	DefaultProvider   string                    `yaml:"default_provider" json:"default_provider"`
	Providers         map[string]ProviderConfig `yaml:"providers" json:"providers"`
	CacheEnabled      bool                      `yaml:"cache_enabled" json:"cache_enabled"`
	CacheTTL          time.Duration             `yaml:"cache_ttl" json:"cache_ttl"`
	RotationEnabled   bool                      `yaml:"rotation_enabled" json:"rotation_enabled"`
	RotationInterval  time.Duration             `yaml:"rotation_interval" json:"rotation_interval"`
	EncryptionEnabled bool                      `yaml:"encryption_enabled" json:"encryption_enabled"`
	EncryptionKey     string                    `yaml:"encryption_key" json:"encryption_key"`
	MetricsEnabled    bool                      `yaml:"metrics_enabled" json:"metrics_enabled"`
	Logger            logger.Logger             `yaml:"-" json:"-"`
	Metrics           shared.Metrics            `yaml:"-" json:"-"`
	ErrorHandler      shared.ErrorHandler       `yaml:"-" json:"-"`
}

SecretsConfig contains configuration for the secrets manager

type SecretsManager

type SecretsManager = configscore.SecretsManager

SecretsManager manages secrets for configuration

func NewSecretsManager

func NewSecretsManager(config SecretsConfig) SecretsManager

NewSecretsManager creates a new secrets manager

type SecretsManagerImpl

type SecretsManagerImpl struct {
	// contains filtered or unexported fields
}

SecretsManagerImpl implements the SecretsManager interface

func (*SecretsManagerImpl) DeleteSecret

func (sm *SecretsManagerImpl) DeleteSecret(ctx context.Context, key string) error

DeleteSecret removes a secret

func (*SecretsManagerImpl) GetProvider

func (sm *SecretsManagerImpl) GetProvider(name string) (SecretProvider, error)

GetProvider returns a secrets provider by name

func (*SecretsManagerImpl) GetSecret

func (sm *SecretsManagerImpl) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret by key

func (*SecretsManagerImpl) HealthCheck

func (sm *SecretsManagerImpl) HealthCheck(ctx context.Context) error

HealthCheck performs a health check

func (*SecretsManagerImpl) ListSecrets

func (sm *SecretsManagerImpl) ListSecrets(ctx context.Context) ([]string, error)

ListSecrets returns all secret keys

func (*SecretsManagerImpl) RefreshSecrets

func (sm *SecretsManagerImpl) RefreshSecrets(ctx context.Context) error

RefreshSecrets refreshes all cached secrets

func (*SecretsManagerImpl) RegisterProvider

func (sm *SecretsManagerImpl) RegisterProvider(name string, provider SecretProvider) error

RegisterProvider registers a secrets provider

func (*SecretsManagerImpl) RotateSecret

func (sm *SecretsManagerImpl) RotateSecret(ctx context.Context, key, newValue string) error

RotateSecret rotates a secret with a new value

func (*SecretsManagerImpl) SetSecret

func (sm *SecretsManagerImpl) SetSecret(ctx context.Context, key, value string) error

SetSecret stores a secret

func (*SecretsManagerImpl) Start

func (sm *SecretsManagerImpl) Start(ctx context.Context) error

Start starts the secrets manager

func (*SecretsManagerImpl) Stop

func (sm *SecretsManagerImpl) Stop(ctx context.Context) error

Stop stops the secrets manager

type Severity

type Severity = errors.Severity

type SourceConfig

type SourceConfig = core.SourceConfig

SourceConfig contains common configuration for all sources

type SourceEvent

type SourceEvent = core.SourceEvent

SourceEvent represents an event from a configuration source

type SourceEventHandler

type SourceEventHandler = core.SourceEventHandler

SourceEventHandler handles events from configuration sources

type SourceMetadata

type SourceMetadata = core.SourceMetadata

SourceMetadata contains metadata about a configuration source

type SourceRegistry

type SourceRegistry = core.SourceRegistry

SourceRegistry manages registered configuration sources

func NewSourceRegistry

func NewSourceRegistry(logger logger.Logger) SourceRegistry

NewSourceRegistry creates a new source registry

type SourceRegistryImpl

type SourceRegistryImpl struct {
	// contains filtered or unexported fields
}

SourceRegistryImpl implements the SourceRegistry interface

func (*SourceRegistryImpl) Clear

func (sr *SourceRegistryImpl) Clear() error

Clear removes all registered sources

func (*SourceRegistryImpl) GetAllMetadata

func (sr *SourceRegistryImpl) GetAllMetadata() map[string]*SourceMetadata

GetAllMetadata returns metadata for all sources

func (*SourceRegistryImpl) GetSource

func (sr *SourceRegistryImpl) GetSource(name string) (ConfigSource, error)

GetSource retrieves a configuration source by name

func (*SourceRegistryImpl) GetSourceMetadata

func (sr *SourceRegistryImpl) GetSourceMetadata(name string) (*SourceMetadata, error)

GetSourceMetadata returns metadata for a source

func (*SourceRegistryImpl) GetSourceNames

func (sr *SourceRegistryImpl) GetSourceNames() []string

GetSourceNames returns the names of all registered sources

func (*SourceRegistryImpl) GetSourceStats

func (sr *SourceRegistryImpl) GetSourceStats() map[string]interface{}

GetSourceStats returns statistics about the registry

func (*SourceRegistryImpl) GetSources

func (sr *SourceRegistryImpl) GetSources() []ConfigSource

GetSources returns all registered sources ordered by priority

func (*SourceRegistryImpl) GetSourcesByType

func (sr *SourceRegistryImpl) GetSourcesByType(sourceType string) []ConfigSource

GetSourcesByType returns sources of a specific type

func (*SourceRegistryImpl) GetSourcesWithSecrets

func (sr *SourceRegistryImpl) GetSourcesWithSecrets() []ConfigSource

GetSourcesWithSecrets returns all sources that support secrets

func (*SourceRegistryImpl) GetWatchableSources

func (sr *SourceRegistryImpl) GetWatchableSources() []ConfigSource

GetWatchableSources returns all sources that support watching

func (*SourceRegistryImpl) HasSource

func (sr *SourceRegistryImpl) HasSource(name string) bool

HasSource returns true if a source with the given name is registered

func (*SourceRegistryImpl) IsEmpty

func (sr *SourceRegistryImpl) IsEmpty() bool

IsEmpty returns true if no sources are registered

func (*SourceRegistryImpl) RegisterSource

func (sr *SourceRegistryImpl) RegisterSource(source ConfigSource) error

RegisterSource registers a configuration source

func (*SourceRegistryImpl) UnregisterSource

func (sr *SourceRegistryImpl) UnregisterSource(name string) error

UnregisterSource unregisters a configuration source

func (*SourceRegistryImpl) UpdateLoadStats

func (sr *SourceRegistryImpl) UpdateLoadStats(name string, keyCount int, err error) error

UpdateLoadStats updates load statistics for a source

func (*SourceRegistryImpl) UpdateModifiedTime

func (sr *SourceRegistryImpl) UpdateModifiedTime(name string, modifiedTime time.Time) error

UpdateModifiedTime updates the last modified time for a source

func (*SourceRegistryImpl) UpdateSourceMetadata

func (sr *SourceRegistryImpl) UpdateSourceMetadata(name string, updater func(*SourceMetadata)) error

UpdateSourceMetadata updates metadata for a source (internal use)

func (*SourceRegistryImpl) UpdateWatchStatus

func (sr *SourceRegistryImpl) UpdateWatchStatus(name string, isWatching bool) error

UpdateWatchStatus updates watch status for a source

func (*SourceRegistryImpl) ValidateSourceDependencies

func (sr *SourceRegistryImpl) ValidateSourceDependencies() error

ValidateSourceDependencies validates that all source dependencies are met

type TestConfigAssertions

type TestConfigAssertions struct {
	// contains filtered or unexported fields
}

TestConfigAssertions provides assertion helpers for testing configuration

func NewTestConfigAssertions

func NewTestConfigAssertions(manager ConfigManager) *TestConfigAssertions

NewTestConfigAssertions creates assertion helpers for the test config manager

func (*TestConfigAssertions) AssertIntEquals

func (a *TestConfigAssertions) AssertIntEquals(key string, expected int) bool

AssertIntEquals checks that a key has the expected int value

func (*TestConfigAssertions) AssertKeyEquals

func (a *TestConfigAssertions) AssertKeyEquals(key string, expected interface{}) bool

AssertKeyEquals checks that a key has the expected value

func (*TestConfigAssertions) AssertKeyExists

func (a *TestConfigAssertions) AssertKeyExists(key string) bool

AssertKeyExists checks that a key exists

func (*TestConfigAssertions) AssertStringEquals

func (a *TestConfigAssertions) AssertStringEquals(key string, expected string) bool

AssertStringEquals checks that a key has the expected string value

type TestConfigBuilder

type TestConfigBuilder struct {
	// contains filtered or unexported fields
}

TestConfigBuilder provides a fluent interface for building test configurations

func NewTestConfigBuilder

func NewTestConfigBuilder() *TestConfigBuilder

NewTestConfigBuilder creates a new builder for test configurations

func (*TestConfigBuilder) Build

func (b *TestConfigBuilder) Build() ConfigManager

Build creates a TestConfigManager with the configured data

func (*TestConfigBuilder) Set

func (b *TestConfigBuilder) Set(key string, value interface{}) *TestConfigBuilder

Set sets a key-value pair

func (*TestConfigBuilder) SetDefaults

func (b *TestConfigBuilder) SetDefaults(defaults map[string]interface{}) *TestConfigBuilder

SetDefaults sets multiple default values

func (*TestConfigBuilder) SetSection

func (b *TestConfigBuilder) SetSection(key string, section map[string]interface{}) *TestConfigBuilder

SetSection sets a configuration section

type TestConfigManager

type TestConfigManager struct {
	// contains filtered or unexported fields
}

TestConfigManager is a lightweight, in-memory implementation of ConfigManager optimized for testing scenarios. It provides realistic behavior without external dependencies like files, databases, or network services.

func (*TestConfigManager) AllKeys

func (t *TestConfigManager) AllKeys() []string

AllKeys is an alias for GetKeys

func (*TestConfigManager) AllSettings

func (t *TestConfigManager) AllSettings() map[string]interface{}

AllSettings is an alias for GetAllSettings

func (*TestConfigManager) Bind

func (t *TestConfigManager) Bind(key string, target interface{}) error

Bind binds configuration to a struct (simplified for testing)

func (*TestConfigManager) BindWithDefault

func (t *TestConfigManager) BindWithDefault(key string, target interface{}, defaultValue interface{}) error

BindWithDefault binds with a default value

func (*TestConfigManager) BindWithOptions

func (t *TestConfigManager) BindWithOptions(key string, target interface{}, options configcore.BindOptions) error

BindWithOptions binds with flexible options

func (*TestConfigManager) Clone

func (t *TestConfigManager) Clone() ConfigManager

Clone creates a deep copy

func (*TestConfigManager) ConfigFileUsed

func (t *TestConfigManager) ConfigFileUsed() string

ConfigFileUsed returns the config file path

func (*TestConfigManager) ExpandEnvVars

func (t *TestConfigManager) ExpandEnvVars() error

ExpandEnvVars expands environment variables (no-op for testing)

func (*TestConfigManager) Get

func (t *TestConfigManager) Get(key string) interface{}

Get returns a configuration value

func (*TestConfigManager) GetAllSettings

func (t *TestConfigManager) GetAllSettings() map[string]interface{}

GetAllSettings returns all settings

func (*TestConfigManager) GetBool

func (t *TestConfigManager) GetBool(key string, defaultValue ...bool) bool

GetBool returns a bool value with optional default

func (*TestConfigManager) GetBoolSlice

func (t *TestConfigManager) GetBoolSlice(key string, defaultValue ...[]bool) []bool

GetBoolSlice returns a bool slice with optional default

func (*TestConfigManager) GetBoolWithOptions

func (t *TestConfigManager) GetBoolWithOptions(key string, opts ...configcore.GetOption) (bool, error)

GetBoolWithOptions returns a bool with advanced options

func (*TestConfigManager) GetBytesSize

func (t *TestConfigManager) GetBytesSize(key string, defaultValue ...uint64) uint64

GetBytesSize is an alias for GetSizeInBytes

func (*TestConfigManager) GetDuration

func (t *TestConfigManager) GetDuration(key string, defaultValue ...time.Duration) time.Duration

GetDuration returns a duration value with optional default

func (*TestConfigManager) GetDurationWithOptions

func (t *TestConfigManager) GetDurationWithOptions(key string, opts ...configcore.GetOption) (time.Duration, error)

GetDurationWithOptions returns a duration with advanced options

func (*TestConfigManager) GetFloat32

func (t *TestConfigManager) GetFloat32(key string, defaultValue ...float32) float32

GetFloat32 returns a float32 value with optional default

func (*TestConfigManager) GetFloat64

func (t *TestConfigManager) GetFloat64(key string, defaultValue ...float64) float64

GetFloat64 returns a float64 value with optional default

func (*TestConfigManager) GetFloat64Slice

func (t *TestConfigManager) GetFloat64Slice(key string, defaultValue ...[]float64) []float64

GetFloat64Slice returns a float64 slice with optional default

func (*TestConfigManager) GetInt

func (t *TestConfigManager) GetInt(key string, defaultValue ...int) int

GetInt returns an int value with optional default

func (*TestConfigManager) GetInt16

func (t *TestConfigManager) GetInt16(key string, defaultValue ...int16) int16

GetInt16 returns an int16 value with optional default

func (*TestConfigManager) GetInt32

func (t *TestConfigManager) GetInt32(key string, defaultValue ...int32) int32

GetInt32 returns an int32 value with optional default

func (*TestConfigManager) GetInt64

func (t *TestConfigManager) GetInt64(key string, defaultValue ...int64) int64

GetInt64 returns an int64 value with optional default

func (*TestConfigManager) GetInt64Slice

func (t *TestConfigManager) GetInt64Slice(key string, defaultValue ...[]int64) []int64

GetInt64Slice returns an int64 slice with optional default

func (*TestConfigManager) GetInt8

func (t *TestConfigManager) GetInt8(key string, defaultValue ...int8) int8

GetInt8 returns an int8 value with optional default

func (*TestConfigManager) GetIntSlice

func (t *TestConfigManager) GetIntSlice(key string, defaultValue ...[]int) []int

GetIntSlice returns an int slice with optional default

func (*TestConfigManager) GetIntWithOptions

func (t *TestConfigManager) GetIntWithOptions(key string, opts ...configcore.GetOption) (int, error)

GetIntWithOptions returns an int with advanced options

func (*TestConfigManager) GetKeys

func (t *TestConfigManager) GetKeys() []string

GetKeys returns all configuration keys

func (*TestConfigManager) GetSection

func (t *TestConfigManager) GetSection(key string) map[string]interface{}

GetSection returns a configuration section

func (*TestConfigManager) GetSizeInBytes

func (t *TestConfigManager) GetSizeInBytes(key string, defaultValue ...uint64) uint64

GetSizeInBytes returns size in bytes with optional default

func (*TestConfigManager) GetSourceMetadata

func (t *TestConfigManager) GetSourceMetadata() map[string]*SourceMetadata

GetSourceMetadata returns metadata for all sources

func (*TestConfigManager) GetString

func (t *TestConfigManager) GetString(key string, defaultValue ...string) string

GetString returns a string value with optional default

func (*TestConfigManager) GetStringMap

func (t *TestConfigManager) GetStringMap(key string, defaultValue ...map[string]string) map[string]string

GetStringMap returns a string map with optional default

func (*TestConfigManager) GetStringMapString

func (t *TestConfigManager) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string

GetStringMapString is an alias for GetStringMap

func (*TestConfigManager) GetStringMapStringSlice

func (t *TestConfigManager) GetStringMapStringSlice(key string, defaultValue ...map[string][]string) map[string][]string

GetStringMapStringSlice returns a map of string slices with optional default

func (*TestConfigManager) GetStringSlice

func (t *TestConfigManager) GetStringSlice(key string, defaultValue ...[]string) []string

GetStringSlice returns a string slice with optional default

func (*TestConfigManager) GetStringWithOptions

func (t *TestConfigManager) GetStringWithOptions(key string, opts ...configcore.GetOption) (string, error)

GetStringWithOptions returns a string with advanced options

func (*TestConfigManager) GetTime

func (t *TestConfigManager) GetTime(key string, defaultValue ...time.Time) time.Time

GetTime returns a time value with optional default

func (*TestConfigManager) GetUint

func (t *TestConfigManager) GetUint(key string, defaultValue ...uint) uint

GetUint returns a uint value with optional default

func (*TestConfigManager) GetUint16

func (t *TestConfigManager) GetUint16(key string, defaultValue ...uint16) uint16

GetUint16 returns a uint16 value with optional default

func (*TestConfigManager) GetUint32

func (t *TestConfigManager) GetUint32(key string, defaultValue ...uint32) uint32

GetUint32 returns a uint32 value with optional default

func (*TestConfigManager) GetUint64

func (t *TestConfigManager) GetUint64(key string, defaultValue ...uint64) uint64

GetUint64 returns a uint64 value with optional default

func (*TestConfigManager) GetUint8

func (t *TestConfigManager) GetUint8(key string, defaultValue ...uint8) uint8

GetUint8 returns a uint8 value with optional default

func (*TestConfigManager) GetWithOptions

func (t *TestConfigManager) GetWithOptions(key string, opts ...configcore.GetOption) (interface{}, error)

GetWithOptions returns a value with advanced options

func (*TestConfigManager) HasKey

func (t *TestConfigManager) HasKey(key string) bool

HasKey checks if a key exists

func (*TestConfigManager) InConfig

func (t *TestConfigManager) InConfig(key string) bool

InConfig is an alias for HasKey

func (*TestConfigManager) IsSet

func (t *TestConfigManager) IsSet(key string) bool

IsSet checks if a key is set and not empty

func (*TestConfigManager) LoadFrom

func (t *TestConfigManager) LoadFrom(sources ...ConfigSource) error

LoadFrom simulates loading from sources

func (*TestConfigManager) MergeWith

func (t *TestConfigManager) MergeWith(other ConfigManager) error

MergeWith merges another config manager

func (*TestConfigManager) Name

func (t *TestConfigManager) Name() string

Name returns the manager name

func (*TestConfigManager) OnConfigChange

func (t *TestConfigManager) OnConfigChange(callback func(ConfigChange))

OnConfigChange is an alias for WatchChanges

func (*TestConfigManager) ReadInConfig

func (t *TestConfigManager) ReadInConfig() error

ReadInConfig reads configuration

func (*TestConfigManager) Reload

func (t *TestConfigManager) Reload() error

Reload simulates reloading configuration

func (*TestConfigManager) ReloadContext

func (t *TestConfigManager) ReloadContext(ctx context.Context) error

ReloadContext simulates reload with context

func (*TestConfigManager) Reset

func (t *TestConfigManager) Reset()

Reset clears all configuration

func (*TestConfigManager) SafeGet

func (t *TestConfigManager) SafeGet(key string, expectedType reflect.Type) (interface{}, error)

SafeGet returns a value with type checking

func (*TestConfigManager) SecretsManager

func (t *TestConfigManager) SecretsManager() SecretsManager

SecretsManager returns the secrets manager

func (*TestConfigManager) Set

func (t *TestConfigManager) Set(key string, value interface{})

Set sets a configuration value

func (*TestConfigManager) SetConfigFile

func (t *TestConfigManager) SetConfigFile(filePath string) error

SetConfigFile sets the configuration file (no-op for testing)

func (*TestConfigManager) SetConfigType

func (t *TestConfigManager) SetConfigType(configType string)

SetConfigType sets the configuration type (no-op for testing)

func (*TestConfigManager) SimulateConfigChange

func (t *TestConfigManager) SimulateConfigChange(key string, newValue interface{})

SimulateConfigChange simulates a configuration change for testing watchers

func (*TestConfigManager) Size

func (t *TestConfigManager) Size() int

Size returns the number of keys

func (*TestConfigManager) Stop

func (t *TestConfigManager) Stop() error

Stop stops the manager

func (*TestConfigManager) Sub

Sub returns a sub-configuration manager

func (*TestConfigManager) Unmarshal

func (t *TestConfigManager) Unmarshal(rawVal interface{}) error

Unmarshal unmarshals entire configuration

func (*TestConfigManager) UnmarshalKey

func (t *TestConfigManager) UnmarshalKey(key string, rawVal interface{}) error

UnmarshalKey is an alias for Bind

func (*TestConfigManager) Validate

func (t *TestConfigManager) Validate() error

Validate always validates successfully in tests

func (*TestConfigManager) Watch

func (t *TestConfigManager) Watch(ctx context.Context) error

Watch simulates watching for changes

func (*TestConfigManager) WatchChanges

func (t *TestConfigManager) WatchChanges(callback func(ConfigChange))

WatchChanges registers a callback for all changes

func (*TestConfigManager) WatchConfig

func (t *TestConfigManager) WatchConfig() error

WatchConfig is an alias for Watch

func (*TestConfigManager) WatchWithCallback

func (t *TestConfigManager) WatchWithCallback(key string, callback func(string, interface{}))

WatchWithCallback registers a callback for key changes

type URLRule

type URLRule struct{}

func (*URLRule) AppliesTo

func (r *URLRule) AppliesTo(key string) bool

func (*URLRule) Name

func (r *URLRule) Name() string

func (*URLRule) Validate

func (r *URLRule) Validate(key string, value interface{}) error

type ValidationConfig

type ValidationConfig = core.ValidationConfig

ValidationConfig contains validation configuration for sources

type ValidationError

type ValidationError = errors.ValidationError

Re-export error types from internal/errors

type ValidationMode

type ValidationMode string

ValidationMode defines the validation mode

const (
	ValidationModeStrict     ValidationMode = "strict"
	ValidationModeLoose      ValidationMode = "loose"
	ValidationModePermissive ValidationMode = "permissive"
	ValidationModeDisabled   ValidationMode = "disabled"
)

type ValidationOptions

type ValidationOptions = core.ValidationOptions

ValidationOptions contains validation configuration

type ValidationResult

type ValidationResult struct {
	Valid    bool                `json:"valid"`
	Errors   []ValidationError   `json:"errors,omitempty"`
	Warnings []ValidationWarning `json:"warnings,omitempty"`
	Schema   string              `json:"schema,omitempty"`
}

ValidationResult contains the result of validation

type ValidationRule

type ValidationRule = core.ValidationRule

ValidationRule represents a custom validation rule

type ValidationSchema

type ValidationSchema struct {
	Name        string                    `json:"name"`
	Path        string                    `json:"path"`
	Required    []string                  `json:"required"`
	Properties  map[string]PropertySchema `json:"properties"`
	Constraints []ConstraintRule          `json:"constraints"`
	Custom      []ValidationRule          `json:"-"`
}

ValidationSchema defines a schema for validating configuration sections

type ValidationWarning

type ValidationWarning struct {
	Key        string      `json:"key"`
	Value      interface{} `json:"value,omitempty"`
	Message    string      `json:"message"`
	Suggestion string      `json:"suggestion,omitempty"`
}

ValidationWarning represents a validation warning

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator handles configuration validation

func NewValidator

func NewValidator(config ValidatorConfig) *Validator

NewValidator creates a new configuration validator

func (*Validator) AddConstraint

func (v *Validator) AddConstraint(keyPattern string, constraint ConstraintRule)

AddConstraint adds a constraint rule for a specific key pattern

func (*Validator) AddRule

func (v *Validator) AddRule(keyPattern string, rule ValidationRule)

AddRule adds a validation rule for a specific key pattern

func (*Validator) IsStrictMode

func (v *Validator) IsStrictMode() bool

IsStrictMode returns true if the validator is in strict mode

func (*Validator) RegisterSchema

func (v *Validator) RegisterSchema(schema ValidationSchema)

RegisterSchema registers a validation schema

func (*Validator) SetMode

func (v *Validator) SetMode(mode ValidationMode)

SetMode sets the validation mode

func (*Validator) ValidateAll

func (v *Validator) ValidateAll(config map[string]interface{}) error

ValidateAll validates the entire configuration

func (*Validator) ValidateConfig

func (v *Validator) ValidateConfig(config map[string]interface{}) ValidationResult

ValidateConfig validates a configuration map

func (*Validator) ValidateKey

func (v *Validator) ValidateKey(key string, value interface{}, config map[string]interface{}) error

ValidateKey validates a specific configuration key

type ValidatorConfig

type ValidatorConfig struct {
	Mode           ValidationMode
	DefaultRules   []ValidationRule
	DefaultSchemas []ValidationSchema
	Logger         logger.Logger
	ErrorHandler   shared.ErrorHandler
	StrictMode     bool
	ValidateOnLoad bool
	ValidateOnSet  bool
}

ValidatorConfig contains configuration for the validator

type VaultSecretProvider

type VaultSecretProvider struct {
	// contains filtered or unexported fields
}

VaultSecretProvider provides secrets from HashiCorp Vault (placeholder)

func (*VaultSecretProvider) Close

func (vsp *VaultSecretProvider) Close(ctx context.Context) error

func (*VaultSecretProvider) DeleteSecret

func (vsp *VaultSecretProvider) DeleteSecret(ctx context.Context, key string) error

func (*VaultSecretProvider) GetSecret

func (vsp *VaultSecretProvider) GetSecret(ctx context.Context, key string) (string, error)

func (*VaultSecretProvider) HealthCheck

func (vsp *VaultSecretProvider) HealthCheck(ctx context.Context) error

func (*VaultSecretProvider) Initialize

func (vsp *VaultSecretProvider) Initialize(ctx context.Context, config map[string]interface{}) error

func (*VaultSecretProvider) ListSecrets

func (vsp *VaultSecretProvider) ListSecrets(ctx context.Context) ([]string, error)

func (*VaultSecretProvider) Name

func (vsp *VaultSecretProvider) Name() string

func (*VaultSecretProvider) SetSecret

func (vsp *VaultSecretProvider) SetSecret(ctx context.Context, key, value string) error

func (*VaultSecretProvider) SupportsCaching

func (vsp *VaultSecretProvider) SupportsCaching() bool

func (*VaultSecretProvider) SupportsRotation

func (vsp *VaultSecretProvider) SupportsRotation() bool

type WatchCallback

type WatchCallback func(string, map[string]interface{})

WatchCallback represents a callback function for configuration changes

type WatchContext

type WatchContext = core.WatchContext

WatchContext contains context for watching configuration changes

type WatchEvent

type WatchEvent struct {
	SourceName string                 `json:"source_name"`
	EventType  WatchEventType         `json:"event_type"`
	Data       map[string]interface{} `json:"data"`
	Timestamp  time.Time              `json:"timestamp"`
	Checksum   string                 `json:"checksum,omitempty"`
	Error      error                  `json:"error,omitempty"`
}

WatchEvent represents a configuration change event

type WatchEventType

type WatchEventType string

WatchEventType represents the type of watch event

const (
	WatchEventTypeChange WatchEventType = "change"
	WatchEventTypeCreate WatchEventType = "create"
	WatchEventTypeDelete WatchEventType = "delete"
	WatchEventTypeError  WatchEventType = "error"
	WatchEventTypeReload WatchEventType = "reload"
)

type WatchStats

type WatchStats struct {
	SourceName  string        `json:"source_name"`
	Active      bool          `json:"active"`
	LastCheck   time.Time     `json:"last_check"`
	ChangeCount int64         `json:"change_count"`
	ErrorCount  int64         `json:"error_count"`
	Interval    time.Duration `json:"interval"`
	Uptime      time.Duration `json:"uptime"`
}

WatchStats contains statistics about a watched source

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher handles watching configuration sources for changes

func NewWatcher

func NewWatcher(config WatcherConfig) *Watcher

NewWatcher creates a new configuration watcher

func (*Watcher) GetAllStats

func (w *Watcher) GetAllStats() map[string]*WatchStats

GetAllStats returns statistics for all watched sources

func (*Watcher) GetSourceStats

func (w *Watcher) GetSourceStats(sourceName string) (*WatchStats, error)

GetSourceStats returns statistics for a watched source

func (*Watcher) GetWatchedSources

func (w *Watcher) GetWatchedSources() []string

GetWatchedSources returns the list of currently watched sources

func (*Watcher) RegisterEventHandler

func (w *Watcher) RegisterEventHandler(sourceName string, handler SourceEventHandler)

RegisterEventHandler registers an event handler for a source

func (*Watcher) StopAll

func (w *Watcher) StopAll() error

StopAll stops watching all sources

func (*Watcher) StopWatching

func (w *Watcher) StopWatching(sourceName string) error

StopWatching stops watching a specific source

func (*Watcher) UnregisterEventHandler

func (w *Watcher) UnregisterEventHandler(sourceName string, handler SourceEventHandler)

UnregisterEventHandler unregisters an event handler for a source

func (*Watcher) WatchSource

func (w *Watcher) WatchSource(ctx context.Context, source ConfigSource, callback WatchCallback) error

WatchSource starts watching a configuration source

type WatcherConfig

type WatcherConfig struct {
	Interval       time.Duration
	BufferSize     int
	MaxRetries     int
	RetryInterval  time.Duration
	Logger         logger.Logger
	Metrics        shared.Metrics
	ErrorHandler   shared.ErrorHandler
	EnableDebounce bool
	DebounceTime   time.Duration
}

WatcherConfig contains configuration for the watcher

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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