Documentation
¶
Index ¶
- Variables
- func AddFieldByMappedOption(opts OptionValueProvider, oname string, config Config, ...) error
- func AddFieldByMappedOptionP(opts OptionValueProvider, p NameProvider, config Config, ...) error
- func AddFieldByOption(opts OptionValueProvider, oname string, config Config, names ...string) error
- func AddFieldByOptionP(opts OptionValueProvider, p NameProvider, config Config, names ...string) error
- func AddGroups(list []string, groups ...string) []string
- func FormatConfigOptions(handler ConfigOptionTypeSetHandler) string
- func GetField(config Config, names ...string) (interface{}, error)
- func SetField(config Config, value interface{}, names ...string) error
- type BoolOption
- type BoolOptionType
- type BytesOption
- type BytesOptionType
- type Config
- type ConfigAdder
- type ConfigHandler
- type ConfigOptionType
- func NewBoolOptionType(name string, description string) ConfigOptionType
- func NewBytesOptionType(name string, description string) ConfigOptionType
- func NewIntOptionType(name string, description string) ConfigOptionType
- func NewStringArrayOptionType(name string, description string) ConfigOptionType
- func NewStringMapOptionType(name string, description string) ConfigOptionType
- func NewStringOptionType(name string, description string) ConfigOptionType
- func NewValueMapOptionType(name string, description string) ConfigOptionType
- func NewValueMapYAMLOptionType(name string, description string) ConfigOptionType
- func NewYAMLOptionType(name string, description string) ConfigOptionType
- type ConfigOptionTypeSet
- type ConfigOptionTypeSetHandler
- type ConfigOptions
- type ConfigProvider
- type ConfigTypeOptionSetConfigProvider
- type Filter
- type IntOption
- type IntOptionType
- type NameProvider
- type Option
- type OptionBase
- type OptionName
- type OptionValueProvider
- type StringArrayOption
- type StringArrayOptionType
- type StringMapOption
- type StringMapOptionType
- type StringOption
- type StringOptionType
- type TypeOptionBase
- type ValueMapOption
- type ValueMapOptionType
- type ValueMapYAMLOption
- type ValueMapYAMLOptionType
- type YAMLOption
- type YAMLOptionType
Constants ¶
This section is empty.
Variables ¶
var NopConfigHandler = NewNopConfigHandler()
NopConfigHandler is a dummy config handler doing nothing.
Functions ¶
func AddFieldByMappedOption ¶
func AddFieldByMappedOptionP ¶
func AddFieldByMappedOptionP(opts OptionValueProvider, p NameProvider, config Config, mapper func(interface{}) (interface{}, error), names ...string) error
func AddFieldByOption ¶
func AddFieldByOption(opts OptionValueProvider, oname string, config Config, names ...string) error
AddFieldByOption sets the specified target field with the option value, if given. If no target field is specified the name of the option is used.
func AddFieldByOptionP ¶
func AddFieldByOptionP(opts OptionValueProvider, p NameProvider, config Config, names ...string) error
AddFieldByOptionP sets the specified target field with the option value, if given. The option is specified by a name provider instead of its name. If no target field is specified the name of the option is used.
func FormatConfigOptions ¶ added in v0.3.0
func FormatConfigOptions(handler ConfigOptionTypeSetHandler) string
Types ¶
type BoolOption ¶
type BoolOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*BoolOption) AddFlags ¶
func (o *BoolOption) AddFlags(fs *pflag.FlagSet)
func (*BoolOption) Value ¶
func (o *BoolOption) Value() interface{}
type BoolOptionType ¶
type BoolOptionType struct {
TypeOptionBase
}
func (*BoolOptionType) Create ¶
func (s *BoolOptionType) Create() Option
func (*BoolOptionType) Equal ¶
func (s *BoolOptionType) Equal(optionType ConfigOptionType) bool
type BytesOption ¶
type BytesOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*BytesOption) AddFlags ¶
func (o *BytesOption) AddFlags(fs *pflag.FlagSet)
func (*BytesOption) Value ¶
func (o *BytesOption) Value() interface{}
type BytesOptionType ¶
type BytesOptionType struct {
TypeOptionBase
}
func (*BytesOptionType) Create ¶
func (s *BytesOptionType) Create() Option
func (*BytesOptionType) Equal ¶
func (s *BytesOptionType) Equal(optionType ConfigOptionType) bool
type Config ¶
type Config = map[string]interface{}
Config is a generic structured config stored in a string map.
type ConfigAdder ¶
type ConfigAdder func(options ConfigOptions, config Config) error
ConfigAdder is used to incorporate a partial config into an existing one.
func ComposedAdder ¶
func ComposedAdder(adders ...ConfigAdder) ConfigAdder
func (ConfigAdder) ApplyConfig ¶
func (c ConfigAdder) ApplyConfig(options ConfigOptions, config Config) error
type ConfigHandler ¶
type ConfigHandler interface {
ApplyConfig(options ConfigOptions, config Config) error
}
ConfigHandler describes the ConfigAdder functionality.
func NewNopConfigHandler ¶
func NewNopConfigHandler() ConfigHandler
type ConfigOptionType ¶
type ConfigOptionType interface {
GetName() string
GetDescription() string
Create() Option
Equal(optionType ConfigOptionType) bool
}
func NewBoolOptionType ¶
func NewBoolOptionType(name string, description string) ConfigOptionType
func NewBytesOptionType ¶
func NewBytesOptionType(name string, description string) ConfigOptionType
func NewIntOptionType ¶
func NewIntOptionType(name string, description string) ConfigOptionType
func NewStringArrayOptionType ¶
func NewStringArrayOptionType(name string, description string) ConfigOptionType
func NewStringMapOptionType ¶
func NewStringMapOptionType(name string, description string) ConfigOptionType
func NewStringOptionType ¶
func NewStringOptionType(name string, description string) ConfigOptionType
func NewValueMapOptionType ¶
func NewValueMapOptionType(name string, description string) ConfigOptionType
func NewValueMapYAMLOptionType ¶
func NewValueMapYAMLOptionType(name string, description string) ConfigOptionType
func NewYAMLOptionType ¶
func NewYAMLOptionType(name string, description string) ConfigOptionType
type ConfigOptionTypeSet ¶
type ConfigOptionTypeSet interface {
AddGroups(groups ...string)
GetName() string
Size() int
OptionTypes() []ConfigOptionType
OptionTypeNames() []string
HasOptionType(name string) bool
GetOptionType(name string) ConfigOptionType
GetTypeSet(name string) ConfigOptionTypeSet
OptionTypeSets() []ConfigOptionTypeSet
AddOptionType(ConfigOptionType) error
AddTypeSet(ConfigOptionTypeSet) error
AddAll(o ConfigOptionTypeSet) (duplicated ConfigOptionTypeSet, err error)
Close(funcs ...func([]ConfigOptionType) error) error
CreateOptions() ConfigOptions
AddGroupsToOption(o Option)
}
func NewConfigOptionSet ¶
func NewConfigOptionSet(name string, types ...ConfigOptionType) ConfigOptionTypeSet
type ConfigOptionTypeSetHandler ¶
type ConfigOptionTypeSetHandler interface {
ConfigOptionTypeSet
ConfigHandler
}
ConfigOptionTypeSetHandler describes a ConfigOptionTypeSet, which also provides the possibility to provide config.
func NewConfigOptionTypeSetHandler ¶
func NewConfigOptionTypeSetHandler(name string, adder ConfigAdder, types ...ConfigOptionType) ConfigOptionTypeSetHandler
NewConfigOptionTypeSetHandler creates a new ConfigOptionTypeSetHandler.
type ConfigOptions ¶
type ConfigOptions interface {
AddTypeSetGroupsToOptions(set ConfigOptionTypeSet)
AddFlags(fs *pflag.FlagSet)
Options() []Option
Check(set ConfigOptionTypeSet, desc string) error
GetValue(name string) (interface{}, bool)
Changed(names ...string) bool
FilterBy(Filter) ConfigOptions
}
func NewOptions ¶
func NewOptions(opts []Option) ConfigOptions
type ConfigProvider ¶
type ConfigProvider interface {
CreateOptions() ConfigOptions
GetConfigFor(opts ConfigOptions) (Config, error)
}
type ConfigTypeOptionSetConfigProvider ¶
type ConfigTypeOptionSetConfigProvider interface {
ConfigProvider
ConfigOptionTypeSet
IsExplicitlySelected(opts ConfigOptions) bool
}
func NewPlainConfigProvider ¶
func NewPlainConfigProvider(name string, adder ConfigAdder, types ...ConfigOptionType) ConfigTypeOptionSetConfigProvider
func NewTypedConfigProvider ¶
func NewTypedConfigProvider(name string, desc string) ConfigTypeOptionSetConfigProvider
type IntOption ¶
type IntOption struct {
OptionBase
// contains filtered or unexported fields
}
type IntOptionType ¶
type IntOptionType struct {
TypeOptionBase
}
func (*IntOptionType) Create ¶
func (s *IntOptionType) Create() Option
func (*IntOptionType) Equal ¶
func (s *IntOptionType) Equal(optionType ConfigOptionType) bool
type NameProvider ¶
type NameProvider interface {
GetName() string
}
type OptionBase ¶
type OptionBase struct {
// contains filtered or unexported fields
}
func NewOptionBase ¶
func NewOptionBase(otyp ConfigOptionType) OptionBase
func (*OptionBase) AddGroups ¶
func (b *OptionBase) AddGroups(groups ...string)
func (*OptionBase) Changed ¶
func (b *OptionBase) Changed() bool
func (*OptionBase) Description ¶
func (b *OptionBase) Description() string
func (*OptionBase) GetName ¶
func (b *OptionBase) GetName() string
func (*OptionBase) TweakFlag ¶
func (b *OptionBase) TweakFlag(f *pflag.Flag)
func (*OptionBase) Type ¶
func (b *OptionBase) Type() ConfigOptionType
type OptionName ¶
type OptionName string
func (OptionName) GetName ¶
func (n OptionName) GetName() string
type OptionValueProvider ¶
OptionValueProvider provides values for named options.
type StringArrayOption ¶
type StringArrayOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*StringArrayOption) AddFlags ¶
func (o *StringArrayOption) AddFlags(fs *pflag.FlagSet)
func (*StringArrayOption) Value ¶
func (o *StringArrayOption) Value() interface{}
type StringArrayOptionType ¶
type StringArrayOptionType struct {
TypeOptionBase
}
func (*StringArrayOptionType) Create ¶
func (s *StringArrayOptionType) Create() Option
func (*StringArrayOptionType) Equal ¶
func (s *StringArrayOptionType) Equal(optionType ConfigOptionType) bool
type StringMapOption ¶
type StringMapOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*StringMapOption) AddFlags ¶
func (o *StringMapOption) AddFlags(fs *pflag.FlagSet)
func (*StringMapOption) Value ¶
func (o *StringMapOption) Value() interface{}
type StringMapOptionType ¶
type StringMapOptionType struct {
TypeOptionBase
}
func (*StringMapOptionType) Create ¶
func (s *StringMapOptionType) Create() Option
func (*StringMapOptionType) Equal ¶
func (s *StringMapOptionType) Equal(optionType ConfigOptionType) bool
type StringOption ¶
type StringOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*StringOption) AddFlags ¶
func (o *StringOption) AddFlags(fs *pflag.FlagSet)
func (*StringOption) Value ¶
func (o *StringOption) Value() interface{}
type StringOptionType ¶
type StringOptionType struct {
TypeOptionBase
}
func (*StringOptionType) Create ¶
func (s *StringOptionType) Create() Option
func (*StringOptionType) Equal ¶
func (s *StringOptionType) Equal(optionType ConfigOptionType) bool
type TypeOptionBase ¶
type TypeOptionBase struct {
// contains filtered or unexported fields
}
func (*TypeOptionBase) GetDescription ¶
func (b *TypeOptionBase) GetDescription() string
func (*TypeOptionBase) GetName ¶
func (b *TypeOptionBase) GetName() string
type ValueMapOption ¶
type ValueMapOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*ValueMapOption) AddFlags ¶
func (o *ValueMapOption) AddFlags(fs *pflag.FlagSet)
func (*ValueMapOption) Value ¶
func (o *ValueMapOption) Value() interface{}
type ValueMapOptionType ¶
type ValueMapOptionType struct {
TypeOptionBase
}
func (*ValueMapOptionType) Create ¶
func (s *ValueMapOptionType) Create() Option
func (*ValueMapOptionType) Equal ¶
func (s *ValueMapOptionType) Equal(optionType ConfigOptionType) bool
type ValueMapYAMLOption ¶
type ValueMapYAMLOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*ValueMapYAMLOption) AddFlags ¶
func (o *ValueMapYAMLOption) AddFlags(fs *pflag.FlagSet)
func (*ValueMapYAMLOption) Value ¶
func (o *ValueMapYAMLOption) Value() interface{}
type ValueMapYAMLOptionType ¶
type ValueMapYAMLOptionType struct {
TypeOptionBase
}
func (*ValueMapYAMLOptionType) Create ¶
func (s *ValueMapYAMLOptionType) Create() Option
func (*ValueMapYAMLOptionType) Equal ¶
func (s *ValueMapYAMLOptionType) Equal(optionType ConfigOptionType) bool
type YAMLOption ¶
type YAMLOption struct {
OptionBase
// contains filtered or unexported fields
}
func (*YAMLOption) AddFlags ¶
func (o *YAMLOption) AddFlags(fs *pflag.FlagSet)
func (*YAMLOption) Value ¶
func (o *YAMLOption) Value() interface{}
type YAMLOptionType ¶
type YAMLOptionType struct {
TypeOptionBase
}
func (*YAMLOptionType) Create ¶
func (s *YAMLOptionType) Create() Option
func (*YAMLOptionType) Equal ¶
func (s *YAMLOptionType) Equal(optionType ConfigOptionType) bool