command: Adding method to get client with datacenter

This commit is contained in:
Armon Dadgar 2014-08-31 21:50:09 -07:00
parent 1a6666027c
commit f14af4adad
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.
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.Address = addr
conf.Datacenter = dc
return consulapi.NewClient(conf)
}