sources

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

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_MixedDefaults(t *testing.T)

func TestRealConfigExample_WithDefaults added in v0.8.5

func TestRealConfigExample_WithDefaults(t *testing.T)

func TestRealConfigExample_WithEnvOverrides added in v0.8.5

func TestRealConfigExample_WithEnvOverrides(t *testing.T)

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) GetSecret

func (cs *ConsulSource) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret from Consul KV.

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) Load

func (cs *ConsulSource) Load(ctx context.Context) (map[string]any, error)

Load loads configuration from Consul KV store.

func (*ConsulSource) Name

func (cs *ConsulSource) Name() string

Name returns the source name.

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).

func (*ConsulSource) Watch

func (cs *ConsulSource) Watch(ctx context.Context, callback func(map[string]any)) error

Watch starts watching Consul KV for changes.

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

func (es *EnvSource) GetKeyMapping() map[string]string

GetKeyMapping returns the key mapping configuration.

func (*EnvSource) GetName

func (es *EnvSource) GetName() string

GetName returns the source name (alias for Name).

func (*EnvSource) GetPrefix

func (es *EnvSource) GetPrefix() string

GetPrefix returns the environment variable prefix.

func (*EnvSource) GetSecret

func (es *EnvSource) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret environment variable.

func (*EnvSource) GetSeparator

func (es *EnvSource) GetSeparator() string

GetSeparator returns the key separator.

func (*EnvSource) GetType

func (es *EnvSource) GetType() string

GetType returns the source type.

func (*EnvSource) IsAvailable

func (es *EnvSource) IsAvailable(ctx context.Context) bool

IsAvailable checks if the source is available.

func (*EnvSource) IsWatchable

func (es *EnvSource) IsWatchable() bool

IsWatchable returns true if environment watching is enabled.

func (*EnvSource) IsWatching

func (es *EnvSource) IsWatching() bool

IsWatching returns true if the source is watching for changes.

func (*EnvSource) Load

func (es *EnvSource) Load(ctx context.Context) (map[string]any, error)

Load loads configuration from environment variables.

func (*EnvSource) Name

func (es *EnvSource) Name() string

Name returns the source name.

func (*EnvSource) Priority

func (es *EnvSource) Priority() int

Priority returns the source priority.

func (*EnvSource) Reload

func (es *EnvSource) Reload(ctx context.Context) error

Reload forces a reload of environment variables.

func (*EnvSource) StopWatch

func (es *EnvSource) StopWatch() error

StopWatch stops watching environment variables.

func (*EnvSource) SupportsSecrets

func (es *EnvSource) SupportsSecrets() bool

SupportsSecrets returns true if secret variables are configured.

func (*EnvSource) Watch

func (es *EnvSource) Watch(ctx context.Context, callback func(map[string]any)) error

Watch starts watching environment variables for changes.

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) GetPath

func (fs *FileSource) GetPath() string

GetPath returns the file path.

func (*FileSource) GetSecret

func (fs *FileSource) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret value (placeholder implementation).

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) Load

func (fs *FileSource) Load(ctx context.Context) (map[string]any, error)

Load loads configuration from the file.

func (*FileSource) Name

func (fs *FileSource) Name() string

Name returns the source name.

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.

func (*FileSource) Watch

func (fs *FileSource) Watch(ctx context.Context, callback func(map[string]any)) error

Watch starts watching the file for changes.

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) GetName

func (ks *K8sSource) GetName() string

GetName returns the source name (alias for Name).

func (*K8sSource) GetSecret

func (ks *K8sSource) GetSecret(ctx context.Context, key string) (string, error)

GetSecret retrieves a secret from Kubernetes.

func (*K8sSource) GetType

func (ks *K8sSource) GetType() string

GetType returns the source type.

func (*K8sSource) IsAvailable

func (ks *K8sSource) IsAvailable(ctx context.Context) bool

IsAvailable checks if the source is available.

func (*K8sSource) IsWatchable

func (ks *K8sSource) IsWatchable() bool

IsWatchable returns true if Kubernetes watching is enabled.

func (*K8sSource) Load

func (ks *K8sSource) Load(ctx context.Context) (map[string]any, error)

Load loads configuration from Kubernetes ConfigMaps and Secrets.

func (*K8sSource) Name

func (ks *K8sSource) Name() string

Name returns the source name.

func (*K8sSource) Priority

func (ks *K8sSource) Priority() int

Priority returns the source priority.

func (*K8sSource) Reload

func (ks *K8sSource) Reload(ctx context.Context) error

Reload forces a reload of Kubernetes configuration.

func (*K8sSource) StopWatch

func (ks *K8sSource) StopWatch() error

StopWatch stops watching Kubernetes resources.

func (*K8sSource) SupportsSecrets

func (ks *K8sSource) SupportsSecrets() bool

SupportsSecrets returns true (Kubernetes can store secrets).

func (*K8sSource) Watch

func (ks *K8sSource) Watch(ctx context.Context, callback func(map[string]any)) error

Watch starts watching Kubernetes ConfigMaps and Secrets for changes.

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

type KeyTransformFunc func(string) string

KeyTransformFunc transforms environment variable keys.

type ValueTransformFunc

type ValueTransformFunc func(string, any) any

ValueTransformFunc transforms environment variable values.

Jump to

Keyboard shortcuts

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