From da370bb331c242009ae0b087f9ca929341c746e6 Mon Sep 17 00:00:00 2001 From: cd1989 Date: Fri, 19 Apr 2019 21:29:28 +0800 Subject: [PATCH] List simple tags when detail set to false Signed-off-by: cd1989 --- docs/swagger.yaml | 9 +++++++-- src/core/api/repository.go | 20 ++++++++++++++++++++ src/portal/lib/src/service/tag.service.ts | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b8e16e8ed..e9e0c4f63 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1263,11 +1263,16 @@ paths: type: string required: true description: Relevant repository name. - - name: label_ids + - name: label_id in: query type: string required: false - description: A list of comma separated label IDs. + description: A label ID. + - name: detail + in: query + type: boolean + required: false + description: Bool value indicating whether return detailed information of the tag, such as vulnerability scan info, if set to false, only tag name is returned. tags: - Products responses: diff --git a/src/core/api/repository.go b/src/core/api/repository.go index b7c718552..ee04ed9d9 100644 --- a/src/core/api/repository.go +++ b/src/core/api/repository.go @@ -576,11 +576,31 @@ func (ra *RepositoryAPI) GetTags() { tags = ts } + detail, err := ra.GetBool("detail", true) + if !detail && err == nil { + ra.Data["json"] = simpleTags(tags) + ra.ServeJSON() + return + } + ra.Data["json"] = assembleTagsInParallel(client, repoName, tags, ra.SecurityCtx.GetUsername()) ra.ServeJSON() } +func simpleTags(tags []string) []*models.TagResp { + var tagsResp []*models.TagResp + for _, tag := range tags { + tagsResp = append(tagsResp, &models.TagResp{ + TagDetail: models.TagDetail{ + Name: tag, + }, + }) + } + + return tagsResp +} + // get config, signature and scan overview and assemble them into one // struct for each tag in tags func assembleTagsInParallel(client *registry.Repository, repository string, diff --git a/src/portal/lib/src/service/tag.service.ts b/src/portal/lib/src/service/tag.service.ts index 9020200f3..336fa2369 100644 --- a/src/portal/lib/src/service/tag.service.ts +++ b/src/portal/lib/src/service/tag.service.ts @@ -140,7 +140,7 @@ export class TagDefaultService extends TagService { queryParams = queryParams = new RequestQueryParams(); } - queryParams = queryParams.set("detail", "1"); + queryParams = queryParams.set("detail", "true"); let url: string = `${this._baseUrl}/${repositoryName}/tags`; return this.http