mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
command/meta: VAULT_ADDR to set the addr via env var
This commit is contained in:
@@ -7,12 +7,16 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
"github.com/mitchellh/cli"
|
"github.com/mitchellh/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// EnvVaultAddress can be used to set the address of Vault
|
||||||
|
const EnvVaultAddress = "VAULT_ADDR"
|
||||||
|
|
||||||
// FlagSetFlags is an enum to define what flags are present in the
|
// FlagSetFlags is an enum to define what flags are present in the
|
||||||
// default FlagSet returned by Meta.FlagSet.
|
// default FlagSet returned by Meta.FlagSet.
|
||||||
type FlagSetFlags uint
|
type FlagSetFlags uint
|
||||||
@@ -39,6 +43,9 @@ type Meta struct {
|
|||||||
// flag settings for this command.
|
// flag settings for this command.
|
||||||
func (m *Meta) Client() (*api.Client, error) {
|
func (m *Meta) Client() (*api.Client, error) {
|
||||||
config := api.DefaultConfig()
|
config := api.DefaultConfig()
|
||||||
|
if v := os.Getenv(EnvVaultAddress); v != "" {
|
||||||
|
config.Address = v
|
||||||
|
}
|
||||||
if m.flagAddress != "" {
|
if m.flagAddress != "" {
|
||||||
config.Address = m.flagAddress
|
config.Address = m.flagAddress
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user