From 47d94f072a4d2c4d4c836e0c52231655aecd1e45 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 14 Jun 2018 16:01:41 +0200 Subject: [PATCH] Use a replacer to convert dashes this enables setting all flags through ENV variables Signed-off-by: Knut Ahlers --- cmd/root.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 7ba8282..011ccaf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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)