Documentation ¶
Index ¶
- type ClientOption
- func WithCustomExternalInjection(f func(string) (string, ConfigSource)) ClientOption
- func WithCustomUsage() ClientOption
- func WithExternal(e external.External) ClientOption
- func WithExternalInjection() ClientOption
- func WithFlagConfigFile(flagName string, flagValue string, flagDescription string, ...) ClientOption
- func WithFlagParsed(flagParsed func() error) ClientOption
- func WithPriorityOrder(s ...ConfigSource) ClientOption
- func WithoutCustomUsage() ClientOption
- type ConfigSource
- type FieldDefineErrorArg
- type FieldDefinedArg
- type FieldInitializedArg
- type Logger
- type Options
- func (o *Options) External() external.External
- func (o *Options) ExternalInjection() func(string) (string, ConfigSource)
- func (o *Options) FlagParsed() func() error
- func (o *Options) OnFieldDefineErr(arg FieldDefineErrorArg)
- func (o *Options) OnFieldDefined(arg FieldDefinedArg)
- func (o *Options) OnFieldInitialized(arg FieldInitializedArg)
- func (o *Options) PriorityOrder() []ConfigSource
- func (o *Options) Usage() func()
- type Printer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOption ¶
type ClientOption interface {
Apply(*Options)
}
func WithCustomExternalInjection ¶ added in v1.4.5
func WithCustomExternalInjection(f func(string) (string, ConfigSource)) ClientOption
func WithCustomUsage ¶
func WithCustomUsage() ClientOption
WithCustomUsage generates usage for -help flag from input struct. By default EnvConf uses this function. Use `option.WithoutCustomUsage` to disable it
func WithExternal ¶ added in v1.4.0
func WithExternal(e external.External) ClientOption
func WithExternalInjection ¶ added in v1.4.5
func WithExternalInjection() ClientOption
WithExternalInjection allows to inject variables from an external source use format ${ .env.<ENV_VAR_NAME> } to make an env variable lookup while getting a field from the external source
func WithFlagConfigFile ¶ added in v1.4.0
func WithFlagConfigFile(flagName string, flagValue string, flagDescription string, initConf func([]byte) (external.External, error)) ClientOption
WithFlagConfigFile wraps option.WithFlagParsed with reading configuration file from flag defined path
func WithFlagParsed ¶
func WithFlagParsed(flagParsed func() error) ClientOption
WithFlagParsed define this callback when you need handle flags This callback will raise after method flag.Parse() return not nil error interrupt pasring
func WithPriorityOrder ¶
func WithPriorityOrder(s ...ConfigSource) ClientOption
WithPriorityOrder overrides default priority order, with an order from function argument. Default priority order is: Flag, Environment variable, External source, Default value.
func WithoutCustomUsage ¶
func WithoutCustomUsage() ClientOption
type ConfigSource ¶
type ConfigSource int
const ( NoConfigValue ConfigSource = -1 FlagVariable ConfigSource = 1 << (iota - 1) EnvVariable ExternalSource DefaultValue )
func (ConfigSource) String ¶
func (s ConfigSource) String() string
type FieldDefineErrorArg ¶
type FieldDefinedArg ¶
type FieldInitializedArg ¶
type Logger ¶
type Logger struct { Printer // Enable secrets hide HideSecrets bool // Regex for match secrets by field name in lower case SecretMatchRegex string }
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func (*Options) ExternalInjection ¶ added in v1.4.5
func (o *Options) ExternalInjection() func(string) (string, ConfigSource)
func (*Options) FlagParsed ¶
func (*Options) OnFieldDefineErr ¶
func (o *Options) OnFieldDefineErr(arg FieldDefineErrorArg)
func (*Options) OnFieldDefined ¶
func (o *Options) OnFieldDefined(arg FieldDefinedArg)
func (*Options) OnFieldInitialized ¶
func (o *Options) OnFieldInitialized(arg FieldInitializedArg)
func (*Options) PriorityOrder ¶
func (o *Options) PriorityOrder() []ConfigSource