diff --git a/lxd/project/permissions.go b/lxd/project/permissions.go index 63b8a15ae876..465b45ad0243 100644 --- a/lxd/project/permissions.go +++ b/lxd/project/permissions.go @@ -1478,35 +1478,18 @@ func FilterUsedBy(authorizer auth.Authorizer, r *http.Request, entries []string) continue } - entityType, projectName, location, pathArguments, err := entity.ParseURL(*u) + entityType, _, _, _, err := entity.ParseURL(*u) if err != nil { logger.Warn("Failed to parse project used-by entity URL", logger.Ctx{"url": entry, "error": err}) continue } - entityURL, err := entity.URL(entityType, projectName, location, pathArguments...) - if err != nil { - logger.Warn("Failed to create canonical entity URL for project used-by filtering", logger.Ctx{"url": entry, "error": err}) - continue - } - - urlsByEntityType[entityType] = append(urlsByEntityType[entityType], entityURL) + urlsByEntityType[entityType] = append(urlsByEntityType[entityType], &api.URL{URL: *u}) } // Filter the entries. usedBy := make([]string, 0, len(entries)) - // Used-by lists do not include the project query parameter if it is the default project. - appendUsedBy := func(u *api.URL) { - if u.Query().Get("project") == api.ProjectDefaultName { - q := u.Query() - q.Del("project") - u.RawQuery = q.Encode() - } - - usedBy = append(usedBy, u.String()) - } - for entityType, urls := range urlsByEntityType { // If only one entry of this type, check directly. if len(urls) == 1 { @@ -1515,7 +1498,7 @@ func FilterUsedBy(authorizer auth.Authorizer, r *http.Request, entries []string) continue } - appendUsedBy(urls[0]) + usedBy = append(usedBy, urls[0].String()) continue } @@ -1528,7 +1511,7 @@ func FilterUsedBy(authorizer auth.Authorizer, r *http.Request, entries []string) // Check each url and append. for _, u := range urls { if canViewEntity(u) { - appendUsedBy(u) + usedBy = append(usedBy, u.String()) } } }