mirror of https://github.com/portainer/portainer
fix(edge/groups): include only user trusted endpoints in endpoint count EE-5964 (#10378)
parent
56ab19433a
commit
671f74ce0d
|
@ -49,6 +49,24 @@ func GetEndpointsByTags(tx dataservices.DataStoreTx, tagIDs []portainer.TagID, p
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getTrustedEndpoints(tx dataservices.DataStoreTx, endpointIDs []portainer.EndpointID) ([]portainer.EndpointID, error) {
|
||||||
|
results := []portainer.EndpointID{}
|
||||||
|
for _, endpointID := range endpointIDs {
|
||||||
|
endpoint, err := tx.Endpoint().Endpoint(endpointID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !endpoint.UserTrusted {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
results = append(results, endpoint.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
func mapEndpointGroupToEndpoints(endpoints []portainer.Endpoint) map[portainer.EndpointGroupID]endpointSetType {
|
func mapEndpointGroupToEndpoints(endpoints []portainer.Endpoint) map[portainer.EndpointGroupID]endpointSetType {
|
||||||
groupEndpoints := map[portainer.EndpointGroupID]endpointSetType{}
|
groupEndpoints := map[portainer.EndpointGroupID]endpointSetType{}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,10 @@ import (
|
||||||
|
|
||||||
type decoratedEdgeGroup struct {
|
type decoratedEdgeGroup struct {
|
||||||
portainer.EdgeGroup
|
portainer.EdgeGroup
|
||||||
HasEdgeStack bool `json:"HasEdgeStack"`
|
HasEdgeStack bool `json:"HasEdgeStack"`
|
||||||
HasEdgeJob bool `json:"HasEdgeJob"`
|
HasEdgeJob bool `json:"HasEdgeJob"`
|
||||||
EndpointTypes []portainer.EndpointType
|
EndpointTypes []portainer.EndpointType
|
||||||
|
TrustedEndpoints []portainer.EndpointID `json:"TrustedEndpoints"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// @id EdgeGroupList
|
// @id EdgeGroupList
|
||||||
|
@ -85,6 +86,14 @@ func getEdgeGroupList(tx dataservices.DataStoreTx) ([]decoratedEdgeGroup, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
edgeGroup.Endpoints = endpointIDs
|
edgeGroup.Endpoints = endpointIDs
|
||||||
|
edgeGroup.TrustedEndpoints = endpointIDs
|
||||||
|
} else {
|
||||||
|
trustedEndpoints, err := getTrustedEndpoints(tx, edgeGroup.Endpoints)
|
||||||
|
if err != nil {
|
||||||
|
return nil, httperror.InternalServerError("Unable to retrieve environments for Edge group", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
edgeGroup.TrustedEndpoints = trustedEndpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointTypes, err := getEndpointTypes(tx, edgeGroup.Endpoints)
|
endpointTypes, err := getEndpointTypes(tx, edgeGroup.Endpoints)
|
||||||
|
|
|
@ -56,9 +56,9 @@
|
||||||
<table-column-header
|
<table-column-header
|
||||||
col-title="'Environments Count'"
|
col-title="'Environments Count'"
|
||||||
can-sort="true"
|
can-sort="true"
|
||||||
is-sorted="$ctrl.state.orderBy === 'Endpoints.length'"
|
is-sorted="$ctrl.state.orderBy === 'TrustedEndpoints.length'"
|
||||||
is-sorted-desc="$ctrl.state.orderBy === 'Endpoints.length' && $ctrl.state.reverseOrder"
|
is-sorted-desc="$ctrl.state.orderBy === 'TrustedEndpoints.length' && $ctrl.state.reverseOrder"
|
||||||
ng-click="$ctrl.changeOrderBy('Endpoints.length')"
|
ng-click="$ctrl.changeOrderBy('TrustedEndpoints.length')"
|
||||||
></table-column-header>
|
></table-column-header>
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
<a ui-sref="edge.groups.edit({groupId: item.Id})">{{ item.Name }}</a>
|
<a ui-sref="edge.groups.edit({groupId: item.Id})">{{ item.Name }}</a>
|
||||||
<span ng-if="item.HasEdgeStack || item.HasEdgeJob" class="label label-info image-tag space-left">in use</span>
|
<span ng-if="item.HasEdgeStack || item.HasEdgeJob" class="label label-info image-tag space-left">in use</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.Endpoints.length }}</td>
|
<td>{{ item.TrustedEndpoints.length }}</td>
|
||||||
<td>{{ item.Dynamic ? 'Dynamic' : 'Static' }}</td>
|
<td>{{ item.Dynamic ? 'Dynamic' : 'Static' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="!$ctrl.dataset">
|
<tr ng-if="!$ctrl.dataset">
|
||||||
|
|
Loading…
Reference in New Issue