Documentation ¶
Index ¶
- func ApplyLoggingMask(c interface{})
- func ConfigOverwriteFlag(fs *flag.FlagSet, config *C, name, path, def, usage string) *string
- func DebugString(c *C, filterPrivate bool) string
- func OverwriteConfigOpts(options []ucfg.Option)
- func SettingVarFlag(fs *flag.FlagSet, def *C, name, usage string)
- type C
- func MergeConfigs(cfgs ...*C) (*C, error)
- func MergeConfigsWithOptions(cfgs []*C, options ...ucfg.Option) (*C, error)
- func MustNewConfigFrom(from interface{}) *C
- func NewConfig() *C
- func NewConfigFrom(from interface{}) (*C, error)
- func NewConfigWithYAML(in []byte, source string) (*C, error)
- func SettingFlag(fs *flag.FlagSet, name, usage string) *C
- func (c *C) Bool(name string, idx int) (bool, error)
- func (c *C) Child(name string, idx int) (*C, error)
- func (c *C) CountField(name string) (int, error)
- func (c *C) Enabled() bool
- func (c *C) FlattenedKeys() []string
- func (c *C) Float(name string, idx int) (float64, error)
- func (c *C) GetFields() []string
- func (c *C) Has(name string, idx int) (bool, error)
- func (c *C) HasField(name string) bool
- func (c *C) Int(name string, idx int) (int64, error)
- func (c *C) IsArray() bool
- func (c *C) IsDict() bool
- func (c *C) Merge(from interface{}) error
- func (c *C) MergeWithOpts(from interface{}, opts ...ucfg.Option) error
- func (c *C) Path() string
- func (c *C) PathOf(field string) string
- func (c *C) Remove(name string, idx int) (bool, error)
- func (c *C) SetBool(name string, idx int, value bool) error
- func (c *C) SetChild(name string, idx int, value *C) error
- func (c *C) SetFloat(name string, idx int, value float64) error
- func (c *C) SetInt(name string, idx int, value int64) error
- func (c *C) SetString(name string, idx int, value string) error
- func (c *C) String(name string, idx int) (string, error)
- func (c *C) Unpack(to interface{}) error
- type Namespace
- type SettingsFlag
- type StringsFlag
- func (f *StringsFlag) Get() interface{}
- func (f *StringsFlag) List() []string
- func (f *StringsFlag) Register(fs *flag.FlagSet, name, usage string)
- func (f *StringsFlag) Set(v string) error
- func (f *StringsFlag) SetDefault(v string)
- func (f *StringsFlag) String() string
- func (f *StringsFlag) Type() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyLoggingMask ¶
func ApplyLoggingMask(c interface{})
ApplyLoggingMask redacts the values of keys that might contain sensitive data (password, passphrase, etc.).
func ConfigOverwriteFlag ¶
ConfigOverwriteFlag defines a new flag updating a setting in an Config object. The name is used as the flag its name the path parameter is the full setting name to be used when the flag is set.
func DebugString ¶
DebugString prints a human readable representation of the underlying config using JSON formatting.
func OverwriteConfigOpts ¶
OverwriteConfigOpts allow to change the globally set config option
Types ¶
type C ¶
C object to store hierarchical configurations into. See https://godoc.org/github.com/elastic/go-ucfg#Config
func MergeConfigs ¶
MergeConfigs merges the configs together. If there are different values for the same key, the last one always overwrites the previous values.
func MergeConfigsWithOptions ¶
MergeConfigs merges the configs together based on the provided opts. If there are different values for the same key, the last one always overwrites the previous values.
func MustNewConfigFrom ¶
func MustNewConfigFrom(from interface{}) *C
MustNewConfigFrom creates a new C object from the given input. From can be any kind of structured data (struct, map, array, slice).
If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.
MustNewConfigFrom panics if an error occurs.
func NewConfigFrom ¶
NewConfigFrom creates a new C object from the given input. From can be any kind of structured data (struct, map, array, slice).
If from is a string, the contents is treated like raw YAML input. The string will be parsed and a structure config object is build from the parsed result.
func NewConfigWithYAML ¶
NewConfigWithYAML reads a YAML configuration.
func SettingFlag ¶
SettingFlag defines a setting flag, name and it's usage. The return value is the Config object settings are applied to.
func (*C) FlattenedKeys ¶
FlattenedKeys return a sorted flattened views of the set keys in the configuration.
func (*C) MergeWithOpts ¶
Merge merges the parameter into the C object based on the provided options.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace stores at most one configuration section by name and sub-section.
type SettingsFlag ¶
SettingsFlag captures key/values pairs into an Config object. The flag backed by SettingsFlag can be used multiple times. Values are overwritten by the last usage of a key.
func NewSettingsFlag ¶
func NewSettingsFlag(def *C) *SettingsFlag
NewSettingsFlag creates a new SettingsFlag instance, not registered with any FlagSet.
func (*SettingsFlag) Config ¶
func (f *SettingsFlag) Config() *C
Config returns the config object the SettingsFlag stores applied settings to.
func (*SettingsFlag) Get ¶
func (f *SettingsFlag) Get() interface{}
Get returns the Config object used to store values.
func (*SettingsFlag) Set ¶
func (f *SettingsFlag) Set(s string) error
Set sets a settings value in the Config object. The input string must be a key-value pair like `key=value`. If the value is missing, the value is set to the boolean value `true`.
func (*SettingsFlag) String ¶
func (f *SettingsFlag) String() string
String always returns an empty string. It is required to fulfill the flag.Value interface.
func (*SettingsFlag) Type ¶
func (f *SettingsFlag) Type() string
Type reports the type of contents (setting=value) expected to be parsed by Set. It is used to build the CLI usage string.
type StringsFlag ¶
type StringsFlag struct {
// contains filtered or unexported fields
}
StringsFlag collects multiple usages of the same flag into an array of strings. Duplicate values will be ignored.
func NewStringsFlag ¶
func NewStringsFlag(arr *[]string) *StringsFlag
NewStringsFlag creates a new, but unregistered StringsFlag instance. Results of the flag usage will be appended to `arr`. If the slice is not initially empty, its first value will be used as default. If the flag is used, the slice will be emptied first.
func StringArrFlag ¶
func StringArrFlag(fs *flag.FlagSet, name, def, usage string) *StringsFlag
StringArrFlag creates and registers a new StringsFlag with the given FlagSet. If no FlagSet is passed, flag.CommandLine will be used as target FlagSet.
func StringArrVarFlag ¶
func StringArrVarFlag(fs *flag.FlagSet, arr *[]string, name, usage string) *StringsFlag
StringArrVarFlag creates and registers a new StringsFlag with the given FlagSet. Results of the flag usage will be appended to `arr`. If the slice is not initially empty, its first value will be used as default. If the flag is used, the slice will be emptied first. If no FlagSet is passed, flag.CommandLine will be used as target FlagSet.
func (*StringsFlag) Get ¶
func (f *StringsFlag) Get() interface{}
Get returns the backing slice its contents as interface{}. The type used is `[]string`.
func (*StringsFlag) List ¶
func (f *StringsFlag) List() []string
List returns the current set values.
func (*StringsFlag) Register ¶
func (f *StringsFlag) Register(fs *flag.FlagSet, name, usage string)
Register registers the StringsFlag instance with a FlagSet. A valid FlagSet must be used. Register panics if the flag is already registered.
func (*StringsFlag) Set ¶
func (f *StringsFlag) Set(v string) error
Set is used to pass usage of the flag to StringsFlag. Set adds the new value to the backing array. The array will be emptied on Set, if the backing array still contains the default value.
func (*StringsFlag) SetDefault ¶
func (f *StringsFlag) SetDefault(v string)
SetDefault sets the flags new default value. This overwrites the contents in the backing array.
func (*StringsFlag) String ¶
func (f *StringsFlag) String() string
String joins all it's values set into a comma-separated string.
func (*StringsFlag) Type ¶
func (f *StringsFlag) Type() string
Type reports the type of contents (string) expected to be parsed by Set. It is used to build the CLI usage string.