mirror of
https://github.com/Luzifer/vault-openvpn.git
synced 2024-12-25 22:31:20 +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:
parent
a0b26ea1ae
commit
47d94f072a
1 changed files with 2 additions and 2 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"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)")
|
RootCmd.PersistentFlags().StringVar(&cfg.LogLevel, "log-level", "info", "Log level to use (debug, info, warning, error)")
|
||||||
|
|
||||||
viper.BindPFlags(RootCmd.PersistentFlags())
|
viper.BindPFlags(RootCmd.PersistentFlags())
|
||||||
viper.BindEnv("vault-addr", "VAULT_ADDR")
|
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||||
viper.BindEnv("vault-token", "VAULT_TOKEN")
|
|
||||||
|
|
||||||
if tok := vaultTokenFromDisk(); tok != "" {
|
if tok := vaultTokenFromDisk(); tok != "" {
|
||||||
viper.SetDefault("vault-token", tok)
|
viper.SetDefault("vault-token", tok)
|
||||||
|
|
Loading…
Reference in a new issue