command: style fixes for env addr reading

This commit is contained in:
Ryan Uber 2015-01-16 10:19:04 -08:00
parent 4c3ec248a5
commit e2eff5698e
1 changed files with 3 additions and 5 deletions

View File

@ -43,12 +43,10 @@ func HTTPClient(addr string) (*consulapi.Client, error) {
// HTTPClientDC returns a new Consul HTTP client with the given address and datacenter
func HTTPClientDC(addr, dc string) (*consulapi.Client, error) {
conf := consulapi.DefaultConfig()
switch {
case len(os.Getenv("CONSUL_HTTP_ADDR")) > 0:
conf.Address = os.Getenv("CONSUL_HTTP_ADDR")
default:
conf.Address = addr
if envAddr := os.Getenv("CONSUL_HTTP_ADDR"); addr != "" {
addr = envAddr
}
conf.Address = addr
conf.Datacenter = dc
return consulapi.NewClient(conf)
}