Split BaseCommand http config into a separate function

This commit is contained in:
Kyle Havlovitz 2017-09-29 11:06:19 -07:00
parent f8da72a8b5
commit 787787f904
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
1 changed files with 5 additions and 1 deletions

View File

@ -62,6 +62,11 @@ func (c *BaseCommand) HTTPClient() (*api.Client, error) {
} }
config := api.DefaultConfig() config := api.DefaultConfig()
c.MergeHTTPConfig(config)
return api.NewClient(config)
}
func (c *BaseCommand) MergeHTTPConfig(config *api.Config) {
c.httpAddr.Merge(&config.Address) c.httpAddr.Merge(&config.Address)
c.token.Merge(&config.Token) c.token.Merge(&config.Token)
c.caFile.Merge(&config.TLSConfig.CAFile) c.caFile.Merge(&config.TLSConfig.CAFile)
@ -70,7 +75,6 @@ func (c *BaseCommand) HTTPClient() (*api.Client, error) {
c.keyFile.Merge(&config.TLSConfig.KeyFile) c.keyFile.Merge(&config.TLSConfig.KeyFile)
c.tlsServerName.Merge(&config.TLSConfig.Address) c.tlsServerName.Merge(&config.TLSConfig.Address)
c.datacenter.Merge(&config.Datacenter) c.datacenter.Merge(&config.Datacenter)
return api.NewClient(config)
} }
func (c *BaseCommand) HTTPAddr() string { func (c *BaseCommand) HTTPAddr() string {