1
0
mirror of https://github.com/Luzifer/vault-openvpn.git synced 2024-09-19 09:32:56 +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)