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

View File

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