config: Add the foundation for GDPR privacy configuration

See #4616
This commit is contained in:
Bjørn Erik Pedersen
2018-05-04 10:18:45 +02:00
parent 9bd4236e1b
commit 0bbdef986d
7 changed files with 239 additions and 5 deletions

View File

@@ -13,6 +13,12 @@
package config
import (
"strings"
"github.com/spf13/viper"
)
// Provider provides the configuration settings for Hugo.
type Provider interface {
GetString(key string) string
@@ -25,3 +31,14 @@ type Provider interface {
Set(key string, value interface{})
IsSet(key 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 := viper.New()
v.SetConfigType(configType)
if err := v.ReadConfig(strings.NewReader(config)); err != nil {
return nil, err
}
return v, nil
}