mirror of https://github.com/portainer/portainer
fix(waiting-room): search endpoints by dynamic edge group name EE-5965 (#10090)
parent
1e61f7e305
commit
3237e1990c
|
@ -12,6 +12,7 @@ import (
|
||||||
portainer "github.com/portainer/portainer/api"
|
portainer "github.com/portainer/portainer/api"
|
||||||
"github.com/portainer/portainer/api/dataservices"
|
"github.com/portainer/portainer/api/dataservices"
|
||||||
"github.com/portainer/portainer/api/http/handler/edgegroups"
|
"github.com/portainer/portainer/api/http/handler/edgegroups"
|
||||||
|
"github.com/portainer/portainer/api/internal/edge"
|
||||||
"github.com/portainer/portainer/api/internal/endpointutils"
|
"github.com/portainer/portainer/api/internal/endpointutils"
|
||||||
"github.com/portainer/portainer/api/internal/slices"
|
"github.com/portainer/portainer/api/internal/slices"
|
||||||
"github.com/portainer/portainer/api/internal/unique"
|
"github.com/portainer/portainer/api/internal/unique"
|
||||||
|
@ -311,11 +312,15 @@ func filterEndpointsBySearchCriteria(
|
||||||
if endpointGroupMatchSearchCriteria(&endpoint, endpointGroups, tagsMap, searchCriteria) {
|
if endpointGroupMatchSearchCriteria(&endpoint, endpointGroups, tagsMap, searchCriteria) {
|
||||||
endpoints[n] = endpoint
|
endpoints[n] = endpoint
|
||||||
n++
|
n++
|
||||||
|
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if edgeGroupMatchSearchCriteria(&endpoint, edgeGroups, searchCriteria) {
|
if edgeGroupMatchSearchCriteria(&endpoint, edgeGroups, searchCriteria, endpoints, endpointGroups) {
|
||||||
endpoints[n] = endpoint
|
endpoints[n] = endpoint
|
||||||
n++
|
n++
|
||||||
|
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,13 +400,18 @@ func endpointGroupMatchSearchCriteria(endpoint *portainer.Endpoint, endpointGrou
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// search endpoint's related edgegroups
|
||||||
func edgeGroupMatchSearchCriteria(
|
func edgeGroupMatchSearchCriteria(
|
||||||
endpoint *portainer.Endpoint,
|
endpoint *portainer.Endpoint,
|
||||||
edgeGroups []portainer.EdgeGroup,
|
edgeGroups []portainer.EdgeGroup,
|
||||||
searchCriteria string,
|
searchCriteria string,
|
||||||
|
endpoints []portainer.Endpoint,
|
||||||
|
endpointGroups []portainer.EndpointGroup,
|
||||||
) bool {
|
) bool {
|
||||||
for _, edgeGroup := range edgeGroups {
|
for _, edgeGroup := range edgeGroups {
|
||||||
for _, endpointID := range edgeGroup.Endpoints {
|
relatedEndpointIDs := edge.EdgeGroupRelatedEndpoints(&edgeGroup, endpoints, endpointGroups)
|
||||||
|
|
||||||
|
for _, endpointID := range relatedEndpointIDs {
|
||||||
if endpointID == endpoint.ID {
|
if endpointID == endpoint.ID {
|
||||||
if strings.Contains(strings.ToLower(edgeGroup.Name), searchCriteria) {
|
if strings.Contains(strings.ToLower(edgeGroup.Name), searchCriteria) {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue