Documentation ¶
Index ¶
- Constants
- func ContextWithConfigOptions(ctx context.Context, opts ...ProviderOptions) context.Context
- func GetAddress(host string, port int) string
- func JsonUnmarshalerHookFunc() mapstructure.DecodeHookFuncType
- func MergeAllTypes(src, dst map[string]interface{}) error
- func NewImmutableError(key string, from, to interface{}) error
- func RegisterConfigFlag(flags *pflag.FlagSet, fallback []string)
- func RegisterFlags(flags *pflag.FlagSet)
- func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType
- func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType
- func StringToURLHookFunc() mapstructure.DecodeHookFuncType
- func TextUnmarshalerHookFunc() mapstructure.DecodeHookFuncType
- type ImmutableError
- type KoanfConfmap
- type KoanfFile
- type KoanfMemory
- type Provider
- func (p *Provider) BoolF(key string, fallback bool) bool
- func (p *Provider) ByteSizeF(key string, fallback bytesize.ByteSize) bytesize.ByteSize
- func (p *Provider) DirtyPatch(key string, value any) error
- func (p *Provider) DurationF(key string, fallback time.Duration) (val time.Duration)
- func (p *Provider) Float64F(key string, fallback float64) (val float64)
- func (p *Provider) GetF(key string, fallback interface{}) (val interface{})
- func (p *Provider) IntF(key string, fallback int) (val int)
- func (p *Provider) RequestURIF(path string, fallback *url.URL) *url.URL
- func (p *Provider) Set(key string, value interface{}) error
- func (p *Provider) StringF(key, fallback string) string
- func (p *Provider) StringsF(key string, fallback []string) (val []string)
- func (p *Provider) URIF(path string, fallback *url.URL) *url.URL
- func (p *Provider) Unmarshal(path string, o interface{}) error
- func (p *Provider) UnmarshalWithConf(path string, o interface{}, c koanf.UnmarshalConf) error
- type ProviderOptions
- func ConfigOptionsFromContext(ctx context.Context) []ProviderOptions
- func DisabledEnvLoading() ProviderOptions
- func EnableEnvLoading(prefix string) ProviderOptions
- func WithBaseValues(values map[string]interface{}) ProviderOptions
- func WithChangeNotifier(notifier func(event interface{}, err error)) ProviderOptions
- func WithConfigFiles(files ...string) ProviderOptions
- func WithContext(ctx context.Context) ProviderOptions
- func WithDecodeHookFunc(decodeHookFunc mapstructure.DecodeHookFunc) ProviderOptions
- func WithExceptImmutables(exceptImmutables ...string) ProviderOptions
- func WithFlags(flags *pflag.FlagSet) ProviderOptions
- func WithImmutables(immutables ...string) ProviderOptions
- func WithLogger(l *slog.Logger) ProviderOptions
- func WithUserProviders(providers ...koanf.Provider) ProviderOptions
- func WithValue(key string, value interface{}) ProviderOptions
- func WithValues(values map[string]interface{}) ProviderOptions
Constants ¶
const ( FlagConfig = "config" Delimiter = "." )
Variables ¶
This section is empty.
Functions ¶
func ContextWithConfigOptions ¶
func ContextWithConfigOptions(ctx context.Context, opts ...ProviderOptions) context.Context
func GetAddress ¶
GetAddress host = unix:/path/to/socket => port is discarded, otherwise format as host:port
func JsonUnmarshalerHookFunc ¶
func JsonUnmarshalerHookFunc() mapstructure.DecodeHookFuncType
func MergeAllTypes ¶
func NewImmutableError ¶
func RegisterConfigFlag ¶
func RegisterFlags ¶
RegisterFlags registers the config file flag.
func StringToMailAddressHookFunc ¶
func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType
func StringToRegexpHookFunc ¶
func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType
func StringToURLHookFunc ¶
func StringToURLHookFunc() mapstructure.DecodeHookFuncType
func TextUnmarshalerHookFunc ¶
func TextUnmarshalerHookFunc() mapstructure.DecodeHookFuncType
Types ¶
type ImmutableError ¶
type ImmutableError struct { From interface{} To interface{} Key string // contains filtered or unexported fields }
func (*ImmutableError) Error ¶
func (e *ImmutableError) Error() string
type KoanfConfmap ¶
type KoanfConfmap struct {
// contains filtered or unexported fields
}
func NewKoanfConfmap ¶
func NewKoanfConfmap(tuples []tuple) *KoanfConfmap
func (*KoanfConfmap) Read ¶
func (e *KoanfConfmap) Read() (map[string]interface{}, error)
Read returns the loaded map[string]interface{}.
func (*KoanfConfmap) ReadBytes ¶
func (e *KoanfConfmap) ReadBytes() ([]byte, error)
ReadBytes is not supported by the env provider.
type KoanfFile ¶
type KoanfFile struct {
// contains filtered or unexported fields
}
func NewKoanfFile ¶
func NewKoanfFileSubKey ¶
type KoanfMemory ¶
type KoanfMemory struct {
// contains filtered or unexported fields
}
KoanfMemory implements a KoanfMemory provider.
func NewKoanfMemory ¶
func NewKoanfMemory(ctx context.Context, doc stdjson.RawMessage) *KoanfMemory
NewKoanfMemory returns a file provider.
func NewKoanfMemoryWithParser ¶
func NewKoanfMemoryWithParser(ctx context.Context, doc stdjson.RawMessage, parser koanf.Parser) *KoanfMemory
func (*KoanfMemory) Read ¶
func (f *KoanfMemory) Read() (map[string]interface{}, error)
Read is not supported by the file provider.
func (*KoanfMemory) ReadBytes ¶
func (f *KoanfMemory) ReadBytes() ([]byte, error)
ReadBytes reads the contents of a file on disk and returns the bytes.
func (*KoanfMemory) SetDoc ¶
func (f *KoanfMemory) SetDoc(doc stdjson.RawMessage)
type Provider ¶
type Provider struct { *koanf.Koanf // contains filtered or unexported fields }
func (*Provider) DirtyPatch ¶
DirtyPatch patches individual config keys without reloading the full config
WARNING! This method is only useful to override existing keys in string or number format. DO NOT use this method to override arrays, maps, or other complex types.
This method DOES NOT validate the config against the config JSON schema. If you need to validate the config, use the Set method instead.
This method can not be used to remove keys from the config as that is not possible without reloading the full config.
func (*Provider) RequestURIF ¶
func (*Provider) UnmarshalWithConf ¶
type ProviderOptions ¶
type ProviderOptions func(p *Provider)
func ConfigOptionsFromContext ¶
func ConfigOptionsFromContext(ctx context.Context) []ProviderOptions
func DisabledEnvLoading ¶
func DisabledEnvLoading() ProviderOptions
DisabledEnvLoading disables env loading. Notes: cant be used with EnableEnvLoading at the same time
func EnableEnvLoading ¶
func EnableEnvLoading(prefix string) ProviderOptions
EnableEnvLoading enables env loading. Notes: cant be used with DisabledEnvLoading at the same time
func WithBaseValues ¶
func WithBaseValues(values map[string]interface{}) ProviderOptions
func WithChangeNotifier ¶
func WithChangeNotifier(notifier func(event interface{}, err error)) ProviderOptions
func WithConfigFiles ¶
func WithConfigFiles(files ...string) ProviderOptions
func WithContext ¶
func WithContext(ctx context.Context) ProviderOptions
func WithDecodeHookFunc ¶
func WithDecodeHookFunc(decodeHookFunc mapstructure.DecodeHookFunc) ProviderOptions
func WithExceptImmutables ¶
func WithExceptImmutables(exceptImmutables ...string) ProviderOptions
func WithFlags ¶
func WithFlags(flags *pflag.FlagSet) ProviderOptions
func WithImmutables ¶
func WithImmutables(immutables ...string) ProviderOptions
func WithLogger ¶
func WithLogger(l *slog.Logger) ProviderOptions
func WithUserProviders ¶
func WithUserProviders(providers ...koanf.Provider) ProviderOptions
func WithValue ¶
func WithValue(key string, value interface{}) ProviderOptions
func WithValues ¶
func WithValues(values map[string]interface{}) ProviderOptions