1
0
Fork 0
mirror of https://github.com/Luzifer/vault-openvpn.git synced 2024-12-25 14:21:21 +00:00

Use a replacer to convert dashes

this enables setting all flags through ENV variables

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-06-14 16:01:41 +02:00
parent a0b26ea1ae
commit 47d94f072a
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"time"
"github.com/hashicorp/vault/api"
@ -80,8 +81,7 @@ func init() {
RootCmd.PersistentFlags().StringVar(&cfg.LogLevel, "log-level", "info", "Log level to use (debug, info, warning, error)")
viper.BindPFlags(RootCmd.PersistentFlags())
viper.BindEnv("vault-addr", "VAULT_ADDR")
viper.BindEnv("vault-token", "VAULT_TOKEN")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
if tok := vaultTokenFromDisk(); tok != "" {
viper.SetDefault("vault-token", tok)