Support ConnectedWithProxy
This commit is contained in:
parent
76add4f24c
commit
521ec63339
|
@ -29,14 +29,14 @@ type ServiceSummary struct {
|
|||
Tags []string
|
||||
Nodes []string
|
||||
InstanceCount int
|
||||
ProxyFor []string `json:",omitempty"`
|
||||
proxyForSet map[string]struct{} // internal to track uniqueness
|
||||
ChecksPassing int
|
||||
ChecksWarning int
|
||||
ChecksCritical int
|
||||
ExternalSources []string
|
||||
externalSourceSet map[string]struct{} // internal to track uniqueness
|
||||
GatewayConfig GatewayConfig `json:",omitempty"`
|
||||
ConnectedWithProxy bool
|
||||
ConnectedWithGateway bool
|
||||
|
||||
structs.EnterpriseMeta
|
||||
}
|
||||
|
@ -206,6 +206,10 @@ func summarizeServices(dump structs.ServiceDump, cfg *config.RuntimeConfig) []*S
|
|||
// Collect the summary information
|
||||
var services []structs.ServiceID
|
||||
summary := make(map[structs.ServiceID]*ServiceSummary)
|
||||
|
||||
hasGateway := make(map[structs.ServiceID]bool)
|
||||
hasProxy := make(map[structs.ServiceID]bool)
|
||||
|
||||
getService := func(service structs.ServiceID) *ServiceSummary {
|
||||
serv, ok := summary[service]
|
||||
if !ok {
|
||||
|
@ -241,13 +245,7 @@ func summarizeServices(dump structs.ServiceDump, cfg *config.RuntimeConfig) []*S
|
|||
sum.Kind = svc.Kind
|
||||
sum.InstanceCount += 1
|
||||
if svc.Kind == structs.ServiceKindConnectProxy {
|
||||
if _, ok := sum.proxyForSet[svc.Proxy.DestinationServiceName]; !ok {
|
||||
if sum.proxyForSet == nil {
|
||||
sum.proxyForSet = make(map[string]struct{})
|
||||
}
|
||||
sum.proxyForSet[svc.Proxy.DestinationServiceName] = struct{}{}
|
||||
sum.ProxyFor = append(sum.ProxyFor, svc.Proxy.DestinationServiceName)
|
||||
}
|
||||
hasProxy[structs.NewServiceID(svc.Proxy.DestinationServiceName, &svc.EnterpriseMeta)] = true
|
||||
}
|
||||
for _, tag := range svc.Tags {
|
||||
found := false
|
||||
|
@ -298,6 +296,12 @@ func summarizeServices(dump structs.ServiceDump, cfg *config.RuntimeConfig) []*S
|
|||
for idx, service := range services {
|
||||
// Sort the nodes and tags
|
||||
sum := summary[service]
|
||||
if hasProxy[service] {
|
||||
sum.ConnectedWithProxy = true
|
||||
}
|
||||
if hasGateway[service] {
|
||||
sum.ConnectedWithGateway = true
|
||||
}
|
||||
sort.Strings(sum.Nodes)
|
||||
sort.Strings(sum.Tags)
|
||||
output[idx] = sum
|
||||
|
|
|
@ -315,7 +315,6 @@ func TestUiServices(t *testing.T) {
|
|||
// internal accounting that users don't see can be blown away
|
||||
for _, sum := range summary {
|
||||
sum.externalSourceSet = nil
|
||||
sum.proxyForSet = nil
|
||||
}
|
||||
|
||||
expected := []*ServiceSummary{
|
||||
|
@ -328,6 +327,7 @@ func TestUiServices(t *testing.T) {
|
|||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 0,
|
||||
ConnectedWithProxy: true,
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
{
|
||||
|
@ -347,7 +347,6 @@ func TestUiServices(t *testing.T) {
|
|||
Tags: nil,
|
||||
Nodes: []string{"bar", "foo"},
|
||||
InstanceCount: 2,
|
||||
ProxyFor: []string{"api"},
|
||||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 1,
|
||||
|
@ -384,7 +383,6 @@ func TestUiServices(t *testing.T) {
|
|||
// internal accounting that users don't see can be blown away
|
||||
for _, sum := range summary {
|
||||
sum.externalSourceSet = nil
|
||||
sum.proxyForSet = nil
|
||||
}
|
||||
|
||||
expected := []*ServiceSummary{
|
||||
|
@ -397,6 +395,7 @@ func TestUiServices(t *testing.T) {
|
|||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 0,
|
||||
ConnectedWithProxy: true,
|
||||
EnterpriseMeta: *structs.DefaultEnterpriseMeta(),
|
||||
},
|
||||
{
|
||||
|
@ -405,7 +404,6 @@ func TestUiServices(t *testing.T) {
|
|||
Tags: nil,
|
||||
Nodes: []string{"bar", "foo"},
|
||||
InstanceCount: 2,
|
||||
ProxyFor: []string{"api"},
|
||||
ChecksPassing: 2,
|
||||
ChecksWarning: 1,
|
||||
ChecksCritical: 1,
|
||||
|
|
Loading…
Reference in New Issue