diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-01-29 09:09:55 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-01-29 09:09:55 -0800 |
| commit | d335f04de6861b571190c13bd7d65e9a0c02f187 (patch) | |
| tree | ad534357d50c4027718a7fe2e60391b6545a7db0 /weed/util/config.go | |
| parent | 27b94cb65b34c084790f0a1884956702ee51acc2 (diff) | |
| download | seaweedfs-d335f04de6861b571190c13bd7d65e9a0c02f187.tar.xz seaweedfs-d335f04de6861b571190c13bd7d65e9a0c02f187.zip | |
support env variables to overwrite toml file
Diffstat (limited to 'weed/util/config.go')
| -rw-r--r-- | weed/util/config.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/weed/util/config.go b/weed/util/config.go index 7b86b749e..dfbfdbd82 100644 --- a/weed/util/config.go +++ b/weed/util/config.go @@ -1,8 +1,11 @@ package util import ( - "github.com/chrislusf/seaweedfs/weed/glog" + "strings" + "github.com/spf13/viper" + + "github.com/chrislusf/seaweedfs/weed/glog" ) type Configuration interface { @@ -37,3 +40,11 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) { return true } + +func GetViper() *viper.Viper { + v := viper.GetViper() + v.AutomaticEnv() + v.SetEnvPrefix("weed") + v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + return v +} |
