servewaf's and rproxy's settings are read through viper, bound to the same environment variable names as before, in place of the os.LookupEnv function Main passed down. NewViper turns AutomaticEnv and AllowEmptyEnv on, so a setting that is set but empty reads as set, as it did. A setting may also be given as a file, the _FILE form, which rproxy's settings now have too; rproxy still writes nothing to disk. The settings tests pass set into a viper instead of a lookup function. Model: deepseek-v4-pro
This commit is contained in:
1 parent
2e2f6f7175
commit
3fa1f4b732
19 files changed
+274
-185
No files matched your search
@@ -0,0 +1,16 @@
|
||||
package config
|
||||
|
||||
import "github.com/spf13/viper"
|
||||
|
||||
// NewViper returns the viper that reads the settings: each setting's
|
||||
// environment variable, bound to its own name. Every setting of servewaf and
|
||||
// rproxy is read through it, and none is read with os.Getenv or os.LookupEnv
|
||||
// outside it. An environment variable that is set but empty is set, as one
|
||||
// that holds a value is, which viper does not take for granted.
|
||||
func NewViper() *viper.Viper {
|
||||
v := viper.New()
|
||||
v.AutomaticEnv()
|
||||
v.AllowEmptyEnv(true)
|
||||
|
||||
return v
|
||||
}
|
||||
Reference in new issue
Block a user