Documentation
¶
Index ¶
- Variables
- func AddWatcher(f func(event fsnotify.Event) error)
- func BindEnvsToSchema(schema json.RawMessage) error
- func GetBool(l *logrusx.Logger, key string, fallback bool, deprecated ...string) bool
- func GetDuration(l *logrusx.Logger, key string, fallback time.Duration, deprecated ...string) time.Duration
- func GetFloat64(l *logrusx.Logger, key string, fallback float64, deprecated ...string) float64
- func GetInt(l *logrusx.Logger, key string, fallback int, deprecated ...string) int
- func GetString(l *logrusx.Logger, key string, fallback string, deprecated ...string) string
- func GetStringMapConfig(paths ...string) map[string]interface{}
- func GetStringSlice(l *logrusx.Logger, key string, fallback []string, deprecated ...string) []string
- func InitializeConfig(applicationName string, homeOverride string, l *logrusx.Logger) *logrusx.Logger
- func PrintHumanReadableValidationErrors(w io.Writer, err error)
- func RegisterConfigFlag(c *cobra.Command, applicationName string)
- func ResetWatchers()
- func UnmarshalKey(key string, destination interface{}) error
- func Validate(name string, content []byte) error
- func ValidateFromURL(url string) error
- func WatchAndValidateViper(l *logrusx.Logger, schema []byte, productName string, immutables []string, ...)
- func WatchConfig(l *logrusx.Logger, o *WatchOptions)
- type WatchOptions
Constants ¶
This section is empty.
Variables ¶
var ErrRollbackConfigurationChanges = errors.New("an error occurred and configuration changes should be reverted")
ErrRollbackConfigurationChanges should be used when a configuration is e.g. invalid and should be rolled back.
Functions ¶
func AddWatcher ¶ added in v0.0.65
AddWatcher adds a function callback to viper.OnConfigChange().
func BindEnvsToSchema ¶ added in v0.0.77
func BindEnvsToSchema(schema json.RawMessage) error
BindEnvsToSchema uses all keys it can find from “
func GetDuration ¶
func GetDuration(l *logrusx.Logger, key string, fallback time.Duration, deprecated ...string) time.Duration
GetDuration returns a duration from viper config or the fallback value.
func GetFloat64 ¶
GetFloat64 returns a float64 value from viper config or the fallback value.
func GetStringMapConfig ¶ added in v0.0.87
GetStringMapConfig returns a string map using all settings which will lookup env vars
func GetStringSlice ¶
func GetStringSlice(l *logrusx.Logger, key string, fallback []string, deprecated ...string) []string
GetStringSlice returns a string slice from viper config or the fallback value.
func InitializeConfig ¶ added in v0.0.65
func InitializeConfig(applicationName string, homeOverride string, l *logrusx.Logger) *logrusx.Logger
InitializeConfig initializes viper.
func PrintHumanReadableValidationErrors ¶ added in v0.0.121
PrintHumanReadableValidationErrors prints human readable validation errors. Duh.
func RegisterConfigFlag ¶ added in v0.0.65
RegisterConfigFlag registers the --config / -c flag.
func UnmarshalKey ¶ added in v0.0.135
UnmarshalKey unmarshals a viper key into the destination struct. The destination struct must be JSON-compatible (i.e. have `json` struct tags)
func Validate ¶ added in v0.0.65
Validate validates the viper config
If env vars are supported, they must be bound using viper.BindEnv.
func ValidateFromURL ¶ added in v0.0.94
ValidateFromURL validates the viper config by loading the schema from a URL
Uses Validate internally.
func WatchAndValidateViper ¶ added in v0.0.106
func WatchConfig ¶ added in v0.0.65
func WatchConfig(l *logrusx.Logger, o *WatchOptions)
WatchConfig is a helper makes watching configuration files easy.
Types ¶
type WatchOptions ¶ added in v0.0.65
type WatchOptions struct { // Immutables are keys that cause OnImmutableChange to be fired when modified. Immutables []string // OnImmutableChange - see Immutables. OnImmutableChange func(key string) }
WatchOptions configures WatchConfig.