command/meta: can force config

This commit is contained in:
Mitchell Hashimoto 2015-04-12 17:51:38 -07:00
parent 46cfb9eb97
commit b1be8e9ee8

View File

@ -31,10 +31,13 @@ const (
// Meta contains the meta-options and functionality that nearly every // Meta contains the meta-options and functionality that nearly every
// Vault command inherits. // Vault command inherits.
type Meta struct { type Meta struct {
Address string // Address to force for API clients
ClientToken string ClientToken string
Ui cli.Ui Ui cli.Ui
// The things below can be set, but aren't common
ForceAddress string // Address to force for API clients
ForceConfig *Config // Force a config, don't load from disk
// These are set by the command line flags. // These are set by the command line flags.
flagAddress string flagAddress string
flagCACert string flagCACert string
@ -56,8 +59,8 @@ func (m *Meta) Client() (*api.Client, error) {
if m.flagAddress != "" { if m.flagAddress != "" {
config.Address = m.flagAddress config.Address = m.flagAddress
} }
if m.Address != "" { if m.ForceAddress != "" {
config.Address = m.Address config.Address = m.ForceAddress
} }
// If we need custom TLS configuration, then set it // If we need custom TLS configuration, then set it
@ -118,6 +121,9 @@ func (m *Meta) Config() (*Config, error) {
if m.config != nil { if m.config != nil {
return m.config, nil return m.config, nil
} }
if m.ForceConfig != nil {
return m.ForceConfig, nil
}
var err error var err error
m.config, err = LoadConfig("") m.config, err = LoadConfig("")