Register all known config elements as ENV keys
This commit is contained in:
parent
656babbd79
commit
c65f7270a9
1 changed files with 9 additions and 0 deletions
|
|
@ -21,6 +21,9 @@ import (
|
|||
"github.com/evcc-io/evcc/util/pipe"
|
||||
"github.com/evcc-io/evcc/util/sponsor"
|
||||
"github.com/evcc-io/evcc/util/telemetry"
|
||||
"github.com/fatih/structs"
|
||||
"github.com/jeremywohl/flatten"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
|
@ -89,6 +92,12 @@ func initConfig() {
|
|||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
|
||||
// register all known config keys
|
||||
flat, _ := flatten.Flatten(structs.Map(conf), "", flatten.DotStyle)
|
||||
for _, v := range maps.Keys(flat) {
|
||||
viper.BindEnv(v)
|
||||
}
|
||||
|
||||
// print version
|
||||
util.LogLevel("info", nil)
|
||||
log.INFO.Printf("evcc %s", server.FormattedVersion())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue