Documentation
¶
Index ¶
- Variables
- func AddWatcher(f func(event fsnotify.Event) error)
- func BindEnvsToSchema(schema json.RawMessage) error
- func GetBool(l logrus.FieldLogger, key string, fallback bool, deprecated ...string) bool
- func GetDuration(l logrus.FieldLogger, key string, fallback time.Duration, deprecated ...string) time.Duration
- func GetFloat64(l logrus.FieldLogger, key string, fallback float64, deprecated ...string) float64
- func GetInt(l logrus.FieldLogger, key string, fallback int, deprecated ...string) int
- func GetString(l logrus.FieldLogger, key string, fallback string, deprecated ...string) string
- func GetStringSlice(l logrus.FieldLogger, key string, fallback []string, deprecated ...string) []string
- func InitializeConfig(applicationName string, homeOverride string, l logrus.FieldLogger)
- func LoggerWithValidationErrorFields(l logrus.FieldLogger, err error) logrus.FieldLogger
- func RegisterConfigFlag(c *cobra.Command, applicationName string)
- func ResetWatchers()
- func Validate(schema gojsonschema.JSONLoader) error
- func WatchConfig(l logrus.FieldLogger, 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 logrus.FieldLogger, 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 GetStringSlice ¶
func GetStringSlice(l logrus.FieldLogger, 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 logrus.FieldLogger)
InitializeConfig initializes viper.
func LoggerWithValidationErrorFields ¶ added in v0.0.66
func LoggerWithValidationErrorFields(l logrus.FieldLogger, err error) logrus.FieldLogger
LoggerWithValidationErrorFields adds all validation errors as fields to the logger.
func RegisterConfigFlag ¶ added in v0.0.65
RegisterConfigFlag registers the --config / -c flag.
func Validate ¶ added in v0.0.65
func Validate(schema gojsonschema.JSONLoader) error
Validate validates the viper config. If env vars are supported, they must be bound using viper.BindEnv.
func WatchConfig ¶ added in v0.0.65
func WatchConfig(l logrus.FieldLogger, 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.