fix(endpoints): remove global map to avoid panic writes EE-3838 (#7404)

pull/7398/head
andres-portainer 2 years ago committed by GitHub
parent 628f822025
commit 20a66fb10f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,8 +19,6 @@ const (
EdgeDeviceIntervalAdd = 20 EdgeDeviceIntervalAdd = 20
) )
var endpointGroupNames map[portainer.EndpointGroupID]string
// @id EndpointList // @id EndpointList
// @summary List environments(endpoints) // @summary List environments(endpoints)
// @description List all environments(endpoints) based on the current user authorizations. Will // @description List all environments(endpoints) based on the current user authorizations. Will
@ -141,7 +139,7 @@ func sortEndpointsByField(endpoints []portainer.Endpoint, endpointGroups []porta
} }
case "Group": case "Group":
endpointGroupNames = make(map[portainer.EndpointGroupID]string, 0) endpointGroupNames := make(map[portainer.EndpointGroupID]string, 0)
for _, group := range endpointGroups { for _, group := range endpointGroups {
endpointGroupNames[group.ID] = group.Name endpointGroupNames[group.ID] = group.Name
} }

@ -39,8 +39,8 @@ func (e EndpointsByGroup) Less(i, j int) bool {
return false return false
} }
groupA := endpointGroupNames[e.endpoints[i].GroupID] groupA := e.endpointGroupNames[e.endpoints[i].GroupID]
groupB := endpointGroupNames[e.endpoints[j].GroupID] groupB := e.endpointGroupNames[e.endpoints[j].GroupID]
return sortorder.NaturalLess(strings.ToLower(groupA), strings.ToLower(groupB)) return sortorder.NaturalLess(strings.ToLower(groupA), strings.ToLower(groupB))
} }

Loading…
Cancel
Save