diff --git a/agent/ui_endpoint.go b/agent/ui_endpoint.go index 376cf8df49..cfe82941ec 100644 --- a/agent/ui_endpoint.go +++ b/agent/ui_endpoint.go @@ -15,6 +15,7 @@ type ServiceSummary struct { Kind structs.ServiceKind `json:",omitempty"` Name string Tags []string + Meta map[string]string Nodes []string ChecksPassing int ChecksWarning int @@ -152,6 +153,18 @@ func summarizeServices(dump structs.NodeDump) []*ServiceSummary { sum.Tags = service.Tags sum.Nodes = append(sum.Nodes, node.Node) sum.Kind = service.Kind + + // The service meta is per instance, but we aggregate it + // here for the UI to know it exists for _some_ instance. + if len(service.Meta) > 0 { + if len(sum.Meta) == 0 { + sum.Meta = make(map[string]string) + } + for k, v := range service.Meta { + sum.Meta[k] = v + } + } + nodeServices[idx] = sum } for _, check := range node.Checks { diff --git a/agent/ui_endpoint_test.go b/agent/ui_endpoint_test.go index 9a57030282..596e1999b7 100644 --- a/agent/ui_endpoint_test.go +++ b/agent/ui_endpoint_test.go @@ -168,6 +168,7 @@ func TestSummarizeServices(t *testing.T) { Kind: structs.ServiceKindConnectProxy, Service: "web", Tags: []string{}, + Meta: map[string]string{"bar": "baz"}, }, }, Checks: []*structs.HealthCheck{ @@ -193,6 +194,7 @@ func TestSummarizeServices(t *testing.T) { Kind: structs.ServiceKindConnectProxy, Service: "web", Tags: []string{}, + Meta: map[string]string{"foo": "bar"}, }, }, Checks: []*structs.HealthCheck{ @@ -249,6 +251,7 @@ func TestSummarizeServices(t *testing.T) { Kind: structs.ServiceKindConnectProxy, Name: "web", Tags: []string{}, + Meta: map[string]string{"foo": "bar", "bar": "baz"}, Nodes: []string{"bar", "foo"}, ChecksPassing: 2, ChecksWarning: 0,