Skip to content

Commit

Permalink
Merge pull request #104 from articulate/fix/consul-addr
Browse files Browse the repository at this point in the history
fix(consul): don't parse address
  • Loading branch information
mloberg authored Nov 16, 2022
2 parents 5e7f36a + 45bd243 commit 4b49655
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
12 changes: 3 additions & 9 deletions consul.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"net/url"
"strings"

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

// NewConsul returns a new instance of the Consul client using the given address
func NewConsul(addr string) (*Consul, error) {
a, err := url.Parse(addr)
if err != nil {
return nil, err
}
cfg := api.DefaultConfig()
cfg.Address = addr

c, err := api.NewClient(&api.Config{
Address: a.Host,
Scheme: a.Scheme,
})
c, err := api.NewClient(cfg)
if err != nil {
return nil, err
}
Expand Down
6 changes: 0 additions & 6 deletions consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestNewConsul(t *testing.T) {
c, err := NewConsul("foo:b\ar;baz")
assert.Nil(t, c)
assert.ErrorContains(t, err, "parse")
}

func TestConsulKey(t *testing.T) {
assert.Equal(t, consulKey("foo/bar/baz"), "BAZ")
assert.Equal(t, consulKey("test"), "TEST")
Expand Down

0 comments on commit 4b49655

Please sign in to comment.