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