viperx

package
v0.0.121 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func AddWatcher(f func(event fsnotify.Event) error)

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 GetBool

func GetBool(l logrus.FieldLogger, key string, fallback bool, deprecated ...string) bool

GetBool returns a bool from viper config or false.

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

func GetFloat64(l logrus.FieldLogger, key string, fallback float64, deprecated ...string) float64

GetFloat64 returns a float64 value from viper config or the fallback value.

func GetInt

func GetInt(l logrus.FieldLogger, key string, fallback int, deprecated ...string) int

GetInt returns an int value from viper config or the fallback value.

func GetString

func GetString(l logrus.FieldLogger, key string, fallback string, deprecated ...string) string

GetString returns a string from viper config or the fallback value.

func GetStringMapConfig added in v0.0.87

func GetStringMapConfig(paths ...string) map[string]interface{}

GetStringMapConfig returns a string map using all settings which will lookup env vars

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) logrus.FieldLogger

InitializeConfig initializes viper.

func PrintHumanReadableValidationErrors added in v0.0.121

func PrintHumanReadableValidationErrors(w io.Writer, err error)

PrintHumanReadableValidationErrors prints human readable validation errors. Duh.

func RegisterConfigFlag added in v0.0.65

func RegisterConfigFlag(c *cobra.Command, applicationName string)

RegisterConfigFlag registers the --config / -c flag.

func ResetWatchers added in v0.0.66

func ResetWatchers()

ResetWatchers resets all the watchers.

func Validate added in v0.0.65

func Validate(name string, content []byte) error

Validate validates the viper config

If env vars are supported, they must be bound using viper.BindEnv.

func ValidateFromURL added in v0.0.94

func ValidateFromURL(url string) error

ValidateFromURL validates the viper config by loading the schema from a URL

Uses Validate internally.

func WatchAndValidateViper added in v0.0.106

func WatchAndValidateViper(l logrus.FieldLogger, schema []byte, productName string, immutables []string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL