Adds missing TaggedAddress structures to API client.
This commit is contained in:
parent
4ca26f68fd
commit
742fcf7a24
|
@ -1,13 +1,15 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
Node string
|
Node string
|
||||||
Address string
|
Address string
|
||||||
|
TaggedAddresses map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type CatalogService struct {
|
type CatalogService struct {
|
||||||
Node string
|
Node string
|
||||||
Address string
|
Address string
|
||||||
|
TaggedAddresses map[string]string
|
||||||
ServiceID string
|
ServiceID string
|
||||||
ServiceName string
|
ServiceName string
|
||||||
ServiceAddress string
|
ServiceAddress string
|
||||||
|
@ -22,11 +24,12 @@ type CatalogNode struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CatalogRegistration struct {
|
type CatalogRegistration struct {
|
||||||
Node string
|
Node string
|
||||||
Address string
|
Address string
|
||||||
Datacenter string
|
TaggedAddresses map[string]string
|
||||||
Service *AgentService
|
Datacenter string
|
||||||
Check *AgentCheck
|
Service *AgentService
|
||||||
|
Check *AgentCheck
|
||||||
}
|
}
|
||||||
|
|
||||||
type CatalogDeregistration struct {
|
type CatalogDeregistration struct {
|
||||||
|
|
|
@ -51,6 +51,10 @@ func TestCatalog_Nodes(t *testing.T) {
|
||||||
return false, fmt.Errorf("Bad: %v", nodes)
|
return false, fmt.Errorf("Bad: %v", nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := nodes[0].TaggedAddresses["wan"]; !ok {
|
||||||
|
return false, fmt.Errorf("Bad: %v", nodes)
|
||||||
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}, func(err error) {
|
}, func(err error) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
@ -128,10 +132,15 @@ func TestCatalog_Node(t *testing.T) {
|
||||||
if meta.LastIndex == 0 {
|
if meta.LastIndex == 0 {
|
||||||
return false, fmt.Errorf("Bad: %v", meta)
|
return false, fmt.Errorf("Bad: %v", meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(info.Services) == 0 {
|
if len(info.Services) == 0 {
|
||||||
return false, fmt.Errorf("Bad: %v", info)
|
return false, fmt.Errorf("Bad: %v", info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := info.Node.TaggedAddresses["wan"]; !ok {
|
||||||
|
return false, fmt.Errorf("Bad: %v", info)
|
||||||
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}, func(err error) {
|
}, func(err error) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
|
|
@ -94,6 +94,9 @@ func TestHealth_Service(t *testing.T) {
|
||||||
if len(checks) == 0 {
|
if len(checks) == 0 {
|
||||||
return false, fmt.Errorf("Bad: %v", checks)
|
return false, fmt.Errorf("Bad: %v", checks)
|
||||||
}
|
}
|
||||||
|
if _, ok := checks[0].Node.TaggedAddresses["wan"]; !ok {
|
||||||
|
return false, fmt.Errorf("Bad: %v", checks)
|
||||||
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}, func(err error) {
|
}, func(err error) {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
|
|
|
@ -17,6 +17,9 @@ func TestPreparedQuery(t *testing.T) {
|
||||||
Datacenter: "dc1",
|
Datacenter: "dc1",
|
||||||
Node: "foobar",
|
Node: "foobar",
|
||||||
Address: "192.168.10.10",
|
Address: "192.168.10.10",
|
||||||
|
TaggedAddresses: map[string]string{
|
||||||
|
"wan": "127.0.0.1",
|
||||||
|
},
|
||||||
Service: &AgentService{
|
Service: &AgentService{
|
||||||
ID: "redis1",
|
ID: "redis1",
|
||||||
Service: "redis",
|
Service: "redis",
|
||||||
|
@ -96,6 +99,9 @@ func TestPreparedQuery(t *testing.T) {
|
||||||
if len(results.Nodes) != 1 || results.Nodes[0].Node.Node != "foobar" {
|
if len(results.Nodes) != 1 || results.Nodes[0].Node.Node != "foobar" {
|
||||||
t.Fatalf("bad: %v", results)
|
t.Fatalf("bad: %v", results)
|
||||||
}
|
}
|
||||||
|
if wan, ok := results.Nodes[0].Node.TaggedAddresses["wan"]; !ok || wan != "127.0.0.1" {
|
||||||
|
t.Fatalf("bad: %v", results)
|
||||||
|
}
|
||||||
|
|
||||||
// Execute by name.
|
// Execute by name.
|
||||||
results, _, err = query.Execute("my-query", nil)
|
results, _, err = query.Execute("my-query", nil)
|
||||||
|
@ -105,6 +111,9 @@ func TestPreparedQuery(t *testing.T) {
|
||||||
if len(results.Nodes) != 1 || results.Nodes[0].Node.Node != "foobar" {
|
if len(results.Nodes) != 1 || results.Nodes[0].Node.Node != "foobar" {
|
||||||
t.Fatalf("bad: %v", results)
|
t.Fatalf("bad: %v", results)
|
||||||
}
|
}
|
||||||
|
if wan, ok := results.Nodes[0].Node.TaggedAddresses["wan"]; !ok || wan != "127.0.0.1" {
|
||||||
|
t.Fatalf("bad: %v", results)
|
||||||
|
}
|
||||||
|
|
||||||
// Delete it.
|
// Delete it.
|
||||||
_, err = query.Delete(def.ID, nil)
|
_, err = query.Delete(def.ID, nil)
|
||||||
|
|
Loading…
Reference in New Issue