From cbf31a467f82bd4931b7c7182e324bd19be3334d Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Wed, 20 Jun 2018 12:53:38 -0400 Subject: [PATCH] Output the service Kind in the /v1/internal/ui/services endpoint --- agent/ui_endpoint.go | 2 ++ agent/ui_endpoint_test.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/agent/ui_endpoint.go b/agent/ui_endpoint.go index 6e5c04250..376cf8df4 100644 --- a/agent/ui_endpoint.go +++ b/agent/ui_endpoint.go @@ -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 { diff --git a/agent/ui_endpoint_test.go b/agent/ui_endpoint_test.go index b01613118..dc7f1783f 100644 --- a/agent/ui_endpoint_test.go +++ b/agent/ui_endpoint_test.go @@ -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"},