command: Adding method to get client with datacenter

pull/312/head
Armon Dadgar 2014-08-31 21:50:09 -07:00
parent 6a6885ec18
commit 86a1a3a11e
1 changed files with 6 additions and 0 deletions

View File

@ -27,7 +27,13 @@ func HTTPAddrFlag(f *flag.FlagSet) *string {
// HTTPClient returns a new Consul HTTP client with the given address. // HTTPClient returns a new Consul HTTP client with the given address.
func HTTPClient(addr string) (*consulapi.Client, error) { func HTTPClient(addr string) (*consulapi.Client, error) {
return HTTPClientDC(addr, "")
}
// HTTPClientDC returns a new Consul HTTP client with the given address and datacenter
func HTTPClientDC(addr, dc string) (*consulapi.Client, error) {
conf := consulapi.DefaultConfig() conf := consulapi.DefaultConfig()
conf.Address = addr conf.Address = addr
conf.Datacenter = dc
return consulapi.NewClient(conf) return consulapi.NewClient(conf)
} }