Output the service Kind in the /v1/internal/ui/services endpoint

This commit is contained in:
Matt Keeler 2018-06-20 12:53:38 -04:00 committed by Jack Pearkes
parent ad4df3c3ef
commit cbf31a467f
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,7 @@ import (
// ServiceSummary is used to summarize a service
type ServiceSummary struct {
Kind structs.ServiceKind `json:",omitempty"`
Name string
Tags []string
Nodes []string
@ -150,6 +151,7 @@ func summarizeServices(dump structs.NodeDump) []*ServiceSummary {
sum := getService(service.Service)
sum.Tags = service.Tags
sum.Nodes = append(sum.Nodes, node.Node)
sum.Kind = service.Kind
nodeServices[idx] = sum
}
for _, check := range node.Checks {

View File

@ -155,10 +155,12 @@ func TestSummarizeServices(t *testing.T) {
Address: "127.0.0.1",
Services: []*structs.NodeService{
&structs.NodeService{
Kind: structs.ServiceKindTypical,
Service: "api",
Tags: []string{"tag1", "tag2"},
},
&structs.NodeService{
Kind: structs.ServiceKindConnectProxy,
Service: "web",
Tags: []string{},
},
@ -183,6 +185,7 @@ func TestSummarizeServices(t *testing.T) {
Address: "127.0.0.2",
Services: []*structs.NodeService{
&structs.NodeService{
Kind: structs.ServiceKindConnectProxy,
Service: "web",
Tags: []string{},
},
@ -212,6 +215,7 @@ func TestSummarizeServices(t *testing.T) {
}
expectAPI := &ServiceSummary{
Kind: structs.ServiceKindTypical,
Name: "api",
Tags: []string{"tag1", "tag2"},
Nodes: []string{"foo"},
@ -224,6 +228,7 @@ func TestSummarizeServices(t *testing.T) {
}
expectCache := &ServiceSummary{
Kind: structs.ServiceKindTypical,
Name: "cache",
Tags: []string{},
Nodes: []string{"zip"},
@ -236,6 +241,7 @@ func TestSummarizeServices(t *testing.T) {
}
expectWeb := &ServiceSummary{
Kind: structs.ServiceKindConnectProxy,
Name: "web",
Tags: []string{},
Nodes: []string{"bar", "foo"},