mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-01 08:09:59 +01:00
Sort the tag before returning the list when calling API
Sort the tag before returning the list when calling API list tag API Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
bd28ad1ae7
commit
0e821a9237
@ -615,21 +615,24 @@ func (ra *RepositoryAPI) GetTags() {
|
||||
}
|
||||
tags = ts
|
||||
}
|
||||
|
||||
result := []*models.TagResp{}
|
||||
detail, err := ra.GetBool("detail", true)
|
||||
if !detail && err == nil {
|
||||
ra.Data["json"] = simpleTags(tags)
|
||||
ra.ServeJSON()
|
||||
return
|
||||
result = simpleTags(tags)
|
||||
} else {
|
||||
result = assembleTagsInParallel(
|
||||
client,
|
||||
project.ProjectID,
|
||||
repoName,
|
||||
tags,
|
||||
ra.SecurityCtx.GetUsername(),
|
||||
)
|
||||
}
|
||||
|
||||
ra.Data["json"] = assembleTagsInParallel(
|
||||
client,
|
||||
project.ProjectID,
|
||||
repoName,
|
||||
tags,
|
||||
ra.SecurityCtx.GetUsername(),
|
||||
)
|
||||
// sort by tag name
|
||||
sort.Slice(result, func(i, j int) bool {
|
||||
return result[i].Name < result[j].Name
|
||||
})
|
||||
ra.Data["json"] = result
|
||||
ra.ServeJSON()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user