mirror of https://github.com/status-im/consul.git
consul: Adding Addr to serverParts
This commit is contained in:
parent
2457293dce
commit
aa32e95139
|
@ -25,6 +25,7 @@ type serverParts struct {
|
|||
Datacenter string
|
||||
Port int
|
||||
Bootstrap bool
|
||||
Addr net.Addr
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -81,8 +82,8 @@ func isConsulServer(m serf.Member) (bool, *serverParts) {
|
|||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, &serverParts{datacenter, port, bootstrap}
|
||||
addr := &net.TCPAddr{IP: m.Addr, Port: port}
|
||||
return true, &serverParts{datacenter, port, bootstrap, addr}
|
||||
}
|
||||
|
||||
// Returns if a member is a consul node. Returns a boo,
|
||||
|
|
|
@ -2,6 +2,7 @@ package consul
|
|||
|
||||
import (
|
||||
"github.com/hashicorp/serf/serf"
|
||||
"net"
|
||||
"regexp"
|
||||
"testing"
|
||||
)
|
||||
|
@ -36,6 +37,7 @@ func TestIsPrivateIP(t *testing.T) {
|
|||
|
||||
func TestIsConsulServer(t *testing.T) {
|
||||
m := serf.Member{
|
||||
Addr: net.IP([]byte{127, 0, 0, 1}),
|
||||
Tags: map[string]string{
|
||||
"role": "consul",
|
||||
"dc": "east-aws",
|
||||
|
@ -54,6 +56,9 @@ func TestIsConsulServer(t *testing.T) {
|
|||
if !valid || !parts.Bootstrap {
|
||||
t.Fatalf("expected bootstrap")
|
||||
}
|
||||
if parts.Addr.String() != "127.0.0.1:10000" {
|
||||
t.Fatalf("bad addr: %v", parts.Addr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsConsulNode(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue