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