sources

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

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]interface{}, 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]interface{})) error

Watch starts watching Consul KV for changes

type ConsulSourceConfig

type ConsulSourceConfig struct {
	Address      string           `yaml:"address" json:"address"`
	Token        string           `yaml:"token" json:"token"`
	Datacenter   string           `yaml:"datacenter" json:"datacenter"`
	Prefix       string           `yaml:"prefix" json:"prefix"`
	Priority     int              `yaml:"priority" json:"priority"`
	WatchEnabled bool             `yaml:"watch_enabled" json:"watch_enabled"`
	Timeout      time.Duration    `yaml:"timeout" json:"timeout"`
	RetryCount   int              `yaml:"retry_count" json:"retry_count"`
	RetryDelay   time.Duration    `yaml:"retry_delay" json:"retry_delay"`
	TLS          *ConsulTLSConfig `yaml:"tls" json:"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   `yaml:"enabled" json:"enabled"`
	CertFile           string `yaml:"cert_file" json:"cert_file"`
	KeyFile            string `yaml:"key_file" json:"key_file"`
	CAFile             string `yaml:"ca_file" json:"ca_file"`
	InsecureSkipVerify bool   `yaml:"insecure_skip_verify" json:"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]interface{}, 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]interface{})) error

Watch starts watching environment variables for changes

type EnvSourceConfig

type EnvSourceConfig struct {
	Prefix         string            `yaml:"prefix" json:"prefix"`
	Priority       int               `yaml:"priority" json:"priority"`
	Separator      string            `yaml:"separator" json:"separator"`
	WatchEnabled   bool              `yaml:"watch_enabled" json:"watch_enabled"`
	WatchInterval  time.Duration     `yaml:"watch_interval" json:"watch_interval"`
	CaseSensitive  bool              `yaml:"case_sensitive" json:"case_sensitive"`
	IgnoreEmpty    bool              `yaml:"ignore_empty" json:"ignore_empty"`
	TypeConversion bool              `yaml:"type_conversion" json:"type_conversion"`
	RequiredVars   []string          `yaml:"required_vars" json:"required_vars"`
	SecretVars     []string          `yaml:"secret_vars" json:"secret_vars"`
	KeyMapping     map[string]string `yaml:"key_mapping" json:"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) interface{}
	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]interface{}, 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]interface{})) error

Watch starts watching the file for changes

type FileSourceConfig

type FileSourceConfig struct {
	Path          string        `yaml:"path" json:"path"`
	Format        string        `yaml:"format" json:"format"`
	Priority      int           `yaml:"priority" json:"priority"`
	WatchEnabled  bool          `yaml:"watch_enabled" json:"watch_enabled"`
	WatchInterval time.Duration `yaml:"watch_interval" json:"watch_interval"`
	ExpandEnvVars bool          `yaml:"expand_env_vars" json:"expand_env_vars"`
	ExpandSecrets bool          `yaml:"expand_secrets" json:"expand_secrets"`
	RequireFile   bool          `yaml:"require_file" json:"require_file"`
	BackupEnabled bool          `yaml:"backup_enabled" json:"backup_enabled"`
	BackupDir     string        `yaml:"backup_dir" json:"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]interface{}, 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]interface{})) error

Watch starts watching Kubernetes ConfigMaps and Secrets for changes

type K8sSourceConfig

type K8sSourceConfig struct {
	Namespace      string        `yaml:"namespace" json:"namespace"`
	ConfigMapNames []string      `yaml:"configmap_names" json:"configmap_names"`
	SecretNames    []string      `yaml:"secret_names" json:"secret_names"`
	Priority       int           `yaml:"priority" json:"priority"`
	WatchEnabled   bool          `yaml:"watch_enabled" json:"watch_enabled"`
	KubeConfig     string        `yaml:"kubeconfig" json:"kubeconfig"`
	InCluster      bool          `yaml:"in_cluster" json:"in_cluster"`
	LabelSelector  string        `yaml:"label_selector" json:"label_selector"`
	FieldSelector  string        `yaml:"field_selector" json:"field_selector"`
	RetryCount     int           `yaml:"retry_count" json:"retry_count"`
	RetryDelay     time.Duration `yaml:"retry_delay" json:"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, interface{}) interface{}

ValueTransformFunc transforms environment variable values

Jump to

Keyboard shortcuts

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