Skip to content

Commit 4b49655

Browse files
authored
Merge pull request #104 from articulate/fix/consul-addr
fix(consul): don't parse address
2 parents 5e7f36a + 45bd243 commit 4b49655

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

consul.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"net/url"
54
"strings"
65

76
"github.com/hashicorp/consul/api"
@@ -14,15 +13,10 @@ type Consul struct {
1413

1514
// NewConsul returns a new instance of the Consul client using the given address
1615
func NewConsul(addr string) (*Consul, error) {
17-
a, err := url.Parse(addr)
18-
if err != nil {
19-
return nil, err
20-
}
16+
cfg := api.DefaultConfig()
17+
cfg.Address = addr
2118

22-
c, err := api.NewClient(&api.Config{
23-
Address: a.Host,
24-
Scheme: a.Scheme,
25-
})
19+
c, err := api.NewClient(cfg)
2620
if err != nil {
2721
return nil, err
2822
}

consul_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import (
66
"github.com/stretchr/testify/assert"
77
)
88

9-
func TestNewConsul(t *testing.T) {
10-
c, err := NewConsul("foo:b\ar;baz")
11-
assert.Nil(t, c)
12-
assert.ErrorContains(t, err, "parse")
13-
}
14-
159
func TestConsulKey(t *testing.T) {
1610
assert.Equal(t, consulKey("foo/bar/baz"), "BAZ")
1711
assert.Equal(t, consulKey("test"), "TEST")

0 commit comments

Comments
 (0)