api/ui: return tags on internal UI endpoints
This is to allow the UI to display tags in the services index pages without needing to make additional queries.
This commit is contained in:
parent
5d37c7bc8c
commit
812efc2667
|
@ -13,6 +13,7 @@ import (
|
||||||
// ServiceSummary is used to summarize a service
|
// ServiceSummary is used to summarize a service
|
||||||
type ServiceSummary struct {
|
type ServiceSummary struct {
|
||||||
Name string
|
Name string
|
||||||
|
Tags []string
|
||||||
Nodes []string
|
Nodes []string
|
||||||
ChecksPassing int
|
ChecksPassing int
|
||||||
ChecksWarning int
|
ChecksWarning int
|
||||||
|
@ -147,6 +148,7 @@ func summarizeServices(dump structs.NodeDump) []*ServiceSummary {
|
||||||
nodeServices := make([]*ServiceSummary, len(node.Services))
|
nodeServices := make([]*ServiceSummary, len(node.Services))
|
||||||
for idx, service := range node.Services {
|
for idx, service := range node.Services {
|
||||||
sum := getService(service.Service)
|
sum := getService(service.Service)
|
||||||
|
sum.Tags = service.Tags
|
||||||
sum.Nodes = append(sum.Nodes, node.Node)
|
sum.Nodes = append(sum.Nodes, node.Node)
|
||||||
nodeServices[idx] = sum
|
nodeServices[idx] = sum
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,9 +156,11 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
Services: []*structs.NodeService{
|
Services: []*structs.NodeService{
|
||||||
&structs.NodeService{
|
&structs.NodeService{
|
||||||
Service: "api",
|
Service: "api",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
},
|
},
|
||||||
&structs.NodeService{
|
&structs.NodeService{
|
||||||
Service: "web",
|
Service: "web",
|
||||||
|
Tags: []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Checks: []*structs.HealthCheck{
|
Checks: []*structs.HealthCheck{
|
||||||
|
@ -182,6 +184,7 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
Services: []*structs.NodeService{
|
Services: []*structs.NodeService{
|
||||||
&structs.NodeService{
|
&structs.NodeService{
|
||||||
Service: "web",
|
Service: "web",
|
||||||
|
Tags: []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Checks: []*structs.HealthCheck{
|
Checks: []*structs.HealthCheck{
|
||||||
|
@ -197,6 +200,7 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
Services: []*structs.NodeService{
|
Services: []*structs.NodeService{
|
||||||
&structs.NodeService{
|
&structs.NodeService{
|
||||||
Service: "cache",
|
Service: "cache",
|
||||||
|
Tags: []string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -209,6 +213,7 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
|
|
||||||
expectAPI := &ServiceSummary{
|
expectAPI := &ServiceSummary{
|
||||||
Name: "api",
|
Name: "api",
|
||||||
|
Tags: []string{"tag1", "tag2"},
|
||||||
Nodes: []string{"foo"},
|
Nodes: []string{"foo"},
|
||||||
ChecksPassing: 1,
|
ChecksPassing: 1,
|
||||||
ChecksWarning: 1,
|
ChecksWarning: 1,
|
||||||
|
@ -220,6 +225,7 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
|
|
||||||
expectCache := &ServiceSummary{
|
expectCache := &ServiceSummary{
|
||||||
Name: "cache",
|
Name: "cache",
|
||||||
|
Tags: []string{},
|
||||||
Nodes: []string{"zip"},
|
Nodes: []string{"zip"},
|
||||||
ChecksPassing: 0,
|
ChecksPassing: 0,
|
||||||
ChecksWarning: 0,
|
ChecksWarning: 0,
|
||||||
|
@ -231,6 +237,7 @@ func TestSummarizeServices(t *testing.T) {
|
||||||
|
|
||||||
expectWeb := &ServiceSummary{
|
expectWeb := &ServiceSummary{
|
||||||
Name: "web",
|
Name: "web",
|
||||||
|
Tags: []string{},
|
||||||
Nodes: []string{"bar", "foo"},
|
Nodes: []string{"bar", "foo"},
|
||||||
ChecksPassing: 2,
|
ChecksPassing: 2,
|
||||||
ChecksWarning: 0,
|
ChecksWarning: 0,
|
||||||
|
|
Loading…
Reference in New Issue