Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AvailableExecutable ¶
AvailableExecutable checks that the given value is the name of an executable file, in PATH.
func IsLoggingConfig ¶ added in v6.0.5
IsLoggingConfig reports whether the config key is for a logging configuration.
func LogLevelValidator ¶ added in v6.0.5
LogLevelValidator checks whether the provided value is a valid logging level.
Types ¶
type ErrorList ¶
type ErrorList struct {
// contains filtered or unexported fields
}
ErrorList is a list of configuration Errors occurred during Load() or Map.Change().
func (*ErrorList) Len ¶
Len returns the amount of errors contained in the list. This is needed to implement the sort Interface.
type Key ¶
type Key struct {
Type Type // Type of the value. It defaults to String.
Default string // If the key is not set in a Map, use this value instead.
Deprecated string // Optional message to set if this config value is deprecated.
// Optional function used to validate the values. It's called by Map
// all the times the value associated with this Key is going to be
// changed.
Validator func(string) error
// Optional function to manipulate a value before it's actually saved
// in a Map. It's called only by Map.Change(), and not by Load() since
// values passed to Load() are supposed to have been previously
// processed.
Setter func(string) (string, error)
}
Key defines the type of the value of a particular config key, along with other knobs such as default, validator, etc.
func GetLoggingRuleForKey ¶ added in v6.0.5
GetLoggingRuleForKey returns the rule for the specified logging config key.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a structured map of config keys to config values.
Each legal key is declared in a config Schema using a Key object.
func Load ¶
Load creates a new configuration Map with the given schema and initial values. It is meant to be called with a set of initial values that were set at a previous time and persisted to some storage like a database.
If one or more keys fail to be loaded, return an ErrorList describing what went wrong. Non-failing keys are still loaded in the returned Map.
func SafeLoad ¶
SafeLoad is a wrapper around Load() that does not error when invalid keys are found, and just logs warnings instead. Other kinds of errors are still returned.
func (*Map) Change ¶
Change the values of this configuration Map.
Return a map of key/value pairs that were actually changed. If some keys fail to apply, details are included in the returned ErrorList.
func (*Map) Dump ¶
Dump the current configuration held by this Map.
Keys that match their default value will not be included in the dump.