Skip to content

Commit

Permalink
Sort Identities
Browse files Browse the repository at this point in the history
  • Loading branch information
spjmurray committed Jul 26, 2024
1 parent 8efdd18 commit 19ffa4b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,24 @@ func (h *Handler) GetApiV1OrganizationsOrganizationIDIdentities(w http.ResponseW
return
}

var resources unikornv1.IdentityList
var result unikornv1.IdentityList

options := &client.ListOptions{
LabelSelector: labels.SelectorFromSet(map[string]string{
coreconstants.OrganizationLabel: organizationID,
}),
}

if err := h.client.List(r.Context(), &resources, options); err != nil {
if err := h.client.List(r.Context(), &result, options); err != nil {
errors.HandleError(w, r, errors.OAuth2ServerError("unable to list identities").WithError(err))
return
}

util.WriteJSONResponse(w, r, http.StatusOK, convertIdentityList(resources))
slices.SortFunc(result.Items, func(a, b unikornv1.Identity) int {
return cmp.Compare(a.Name, b.Name)
})

util.WriteJSONResponse(w, r, http.StatusOK, convertIdentityList(result))
}

func (h *Handler) PostApiV1OrganizationsOrganizationIDProjectsProjectIDIdentities(w http.ResponseWriter, r *http.Request, organizationID openapi.OrganizationIDParameter, projectID openapi.ProjectIDParameter) {
Expand Down

0 comments on commit 19ffa4b

Please sign in to comment.