xviper

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package xviper provides customizations on use of viper for configuration loading.

Deprecated: xviper is no longer planned to be used by future WebPA/XMiDT services.

This package is frozen and no new functionality will be added.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddStandardConfigPaths

func AddStandardConfigPaths(c Configer, applicationName string)

AddStandardConfigPaths adds the standard *nix-style configuration paths

func BindConfig

func BindConfig(c Configer, fl FlagLookup, fileFlag, nameFlag string) bool

BindConfig attempts first to bind the configuration file via BindConfigFile. Failing that, it attempts to bind the configuration name via BindConfigName. If either succeeds, this function returns true. Otherwise, if no binding took place, this function returns false.

func BindConfigFile

func BindConfigFile(c Configer, fl FlagLookup, flag string) bool

BindConfigName extracts the path of the Viper configuration file from a flagset. If the given flag is set, its value is passed to c.SetConfigFile and this function returns true. If the flag was missing, this method returns false and the supplied Configer is not changed.

This function is useful to allow the fully-qualified path of the file that Viper uses to be specified or overridden from the command line.

func BindConfigName

func BindConfigName(c Configer, fl FlagLookup, flag string) bool

BindConfigName extracts the name of the Viper configuration file from a flagset. If the given flag is set, its value is passed to c.SetConfigName and this function returns true. If the flag was missing, this method returns false and the supplied Configer is not changed.

This function is useful to allow the name of the file that Viper searches for to be specified or overridden from the command line.

func MustKeyUnmarshal

func MustKeyUnmarshal(u KeyUnmarshaler, k string, v interface{})

MustKeyUnmarshal attempts to unmarshal the given key, panicing on any error

func MustUnmarshal

func MustUnmarshal(u Unmarshaler, v interface{})

MustUnmarshal attempts to unmarshal the value, panicing on any error.

Types

type Configer

type Configer interface {
	AddConfigPath(string)
	SetConfigName(string)
	SetConfigFile(string)
}

Configer is the subset of Viper behavior dealing with configuration paths and locations

type FlagLookup

type FlagLookup interface {
	Lookup(string) *pflag.Flag
}

FlagLookup is the behavior expected of a pflag.FlagSet to lookup individual flags by longhand name.

type InvalidUnmarshaler

type InvalidUnmarshaler struct {
	Err error
}

InvalidUnmarshaler is an Unmarshaler that simply returns an error. Mostly useful for testing.

func (InvalidUnmarshaler) Unmarshal

func (iu InvalidUnmarshaler) Unmarshal(interface{}, ...viper.DecoderConfigOption) error

type KeyUnmarshaler

type KeyUnmarshaler interface {
	UnmarshalKey(string, interface{}) error
}

KeyUnmarshaler describes the subset of Viper behavior for unmarshaling an arbitrary configuration key.

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(interface{}, ...viper.DecoderConfigOption) error
}

Unmarshaler describes the subset of Viper behavior dealing with unmarshaling into arbitrary values.

Jump to

Keyboard shortcuts

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