mirror of https://github.com/hashicorp/consul
command: Adding method to get client with datacenter
parent
6a6885ec18
commit
86a1a3a11e
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue