diff options
Diffstat (limited to 'config/configLoader.go')
-rw-r--r-- | config/configLoader.go | 23 |
1 files changed, 2 insertions, 21 deletions
diff --git a/config/configLoader.go b/config/configLoader.go index 6d94f0b79..0998b1bef 100644 --- a/config/configLoader.go +++ b/config/configLoader.go @@ -20,7 +20,6 @@ import ( "github.com/gohugoio/hugo/common/maps" "github.com/gohugoio/hugo/parser/metadecoders" "github.com/spf13/afero" - "github.com/spf13/viper" ) var ( @@ -43,15 +42,11 @@ func IsValidConfigFilename(filename string) bool { // FromConfigString creates a config from the given YAML, JSON or TOML config. This is useful in tests. func FromConfigString(config, configType string) (Provider, error) { - v := newViper() m, err := readConfig(metadecoders.FormatFromString(configType), []byte(config)) if err != nil { return nil, err } - - v.MergeConfigMap(m) - - return v, nil + return NewFrom(m), nil } // FromFile loads the configuration from the given filename. @@ -60,15 +55,7 @@ func FromFile(fs afero.Fs, filename string) (Provider, error) { if err != nil { return nil, err } - - v := newViper() - - err = v.MergeConfigMap(m) - if err != nil { - return nil, err - } - - return v, nil + return NewFrom(m), nil } // FromFileToMap is the same as FromFile, but it returns the config values @@ -116,9 +103,3 @@ func init() { func RenameKeys(m map[string]interface{}) { keyAliases.Rename(m) } - -func newViper() *viper.Viper { - v := viper.New() - - return v -} |