Documentation ¶
Index ¶
- Constants
- func AddBoolFlag(name string, value bool, usage string) *pflag.Flag
- func AddBoolPFlag(name string, value bool, usage string) *pflag.Flag
- func AddConfigChangeEventListener(listener ConfigChangeEventHandler)
- func AddDurationFlag(name string, value time.Duration, usage string) *pflag.Flag
- func AddFloat64Flag(name string, value float64, usage string) *pflag.Flag
- func AddInt16Flag(name string, value int16, usage string) *pflag.Flag
- func AddInt32Flag(name string, value int32, usage string) *pflag.Flag
- func AddInt64Flag(name string, value int64, usage string) *pflag.Flag
- func AddInt8Flag(name string, value int8, usage string) *pflag.Flag
- func AddIntFlag(name string, value int, usage string) *pflag.Flag
- func AddStringFlag(name string, value string, usage string) *pflag.Flag
- func AddUint16Flag(name string, value uint16, usage string) *pflag.Flag
- func AddUint32Flag(name string, value uint32, usage string) *pflag.Flag
- func AddUint64Flag(name string, value uint64, usage string) *pflag.Flag
- func AddUint8Flag(name string, value uint8, usage string) *pflag.Flag
- func AddUintFlag(name string, value uint, usage string) *pflag.Flag
- func AttachFlagCompletions(cmd *cobra.Command)
- func AttachToFlagSet(flagset *pflag.FlagSet)
- func BindEnv(key string, envVarName string)
- func BindPFlag(key string, flag *pflag.Flag)
- func DecryptConfigFile(fileName string, passphrase string) error
- func IsSet(key string) bool
- func OnConfigChange()
- func ReadConfigFromReader(reader io.Reader) error
- func ReadFromConfigBuffer(configData []byte) error
- func ReadFromConfigFile(configFilePath string) error
- func RegisterFlagCompletionFunc(flagName string, ...)
- func ResetConfig()
- func Set(key string, val string)
- func SetBool(key string, val bool)
- func SetConfigFile(configFilePath string)
- func SetSecureConfigOptions(passphrase string)
- func Unmarshal(obj interface{}) error
- func UnmarshalKey(key string, obj interface{}) error
- func WatchConfig()
- type ConfigChangeEventHandler
- type ConfigChangeEventHandlerFunc
- type KeysTree
- type Tree
- type TreeNode
Constants ¶
const STRUCT_TAG = "config"
Variables ¶
This section is empty.
Functions ¶
func AddConfigChangeEventListener ¶
func AddConfigChangeEventListener(listener ConfigChangeEventHandler)
AddConfigChangeEventListener function is used to register any ConfigChangeEventHandler
func AddDurationFlag ¶
func AddStringFlag ¶
---------------------------------------------------------- Functions to add flags from a component
func AttachFlagCompletions ¶
func AttachToFlagSet ¶
AttachToFlagSet is used to attach the flags in config to the cmd flags
func BindEnv ¶
BindEnv binds the key parameter to a particular environment variable For a hierarchical structure pass the keys separated by a . For examples to access "name" field in the following structure:
auth: name: value
the key parameter should take on the value "auth.key"
func BindPFlag ¶
BindPFlag binds the key parameter to a particular flag For a hierarchical structure pass the keys separated by a . For examples to access "name" field in the following structure:
auth: name: value
the key parameter should take on the value "auth.key"
func DecryptConfigFile ¶
func OnConfigChange ¶
func OnConfigChange()
func ReadConfigFromReader ¶
func ReadFromConfigBuffer ¶
ReadFromConfigBuffer is used to the configFilePath and initialize viper object
func ReadFromConfigFile ¶
ReadFromConfigFile is used to the configFilePath and initialize viper object
func ResetConfig ¶
func ResetConfig()
func SetConfigFile ¶
func SetConfigFile(configFilePath string)
SetConfigFile : set config file name to be watched by viper
func SetSecureConfigOptions ¶
func SetSecureConfigOptions(passphrase string)
func Unmarshal ¶
func Unmarshal(obj interface{}) error
Unmarshal populates the passed object and all the exported fields. use lower case attribute names to ignore a particular field
func UnmarshalKey ¶
UnmarshalKey is used to obtain a subtree starting from the key parameter For a hierarchical structure pass the keys separated by a . For examples to access "name" field in the following structure:
auth: name: value
the key parameter should take on the value "auth.key"
func WatchConfig ¶
func WatchConfig()
Types ¶
type ConfigChangeEventHandler ¶
type ConfigChangeEventHandler interface {
OnConfigChange()
}
ConfigChangeEventHandler is the interface that must implemented by any object that wants to be notified of changes in the config file
type ConfigChangeEventHandlerFunc ¶
type ConfigChangeEventHandlerFunc func()
func (ConfigChangeEventHandlerFunc) OnConfigChange ¶
func (handler ConfigChangeEventHandlerFunc) OnConfigChange()
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func NewTree ¶
func NewTree() *Tree
NewTree returns a new Tree object with the head initialized to a default root TreeNode
func (*Tree) GetSubTree ¶
GetSubTree returns the sub Tree that is present from the last child of the key passed in. For eg. to retrieve the subtree starting from child2 the passed key can be root.child1.child2
func (*Tree) Insert ¶
Insert function is used to insert a new object into the tree The key is specified as a dot separated hierarchical value For eg. root.child1.child2
func (*Tree) MergeWithKey ¶
func (tree *Tree) MergeWithKey(key string, obj interface{}, getValue func(val interface{}) (res interface{}, ok bool))
MergeWithKey is used to merge the contained tree with the object (obj) that is passed in as parameter. getValue parameter is a function that accepts the value stored in a TreeNode and performs any business logic and returns the value that has to be placed in the obj parameter it must also return true|false based on which the value will be set in the obj parameter.