mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
perf: update the ImageList queries to return PaginatedImagesResult (#1182)
Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
+10
-10
@@ -1536,7 +1536,7 @@ func (service mockService) getDerivedImageListGQL(ctx context.Context, config se
|
||||
derivedImage string,
|
||||
) (*imageListStructForDerivedImagesGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForDerivedImagesGQL{}
|
||||
imageListGQLResponse.Data.ImageList.Results = []imageStruct{
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
@@ -1554,7 +1554,7 @@ func (service mockService) getBaseImageListGQL(ctx context.Context, config searc
|
||||
derivedImage string,
|
||||
) (*imageListStructForBaseImagesGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForBaseImagesGQL{}
|
||||
imageListGQLResponse.Data.ImageList.Results = []imageStruct{
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
@@ -1572,7 +1572,7 @@ func (service mockService) getImagesGQL(ctx context.Context, config searchConfig
|
||||
imageName string,
|
||||
) (*imageListStructGQL, error) {
|
||||
imageListGQLResponse := &imageListStructGQL{}
|
||||
imageListGQLResponse.Data.ImageList = []imageStruct{
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
@@ -1590,7 +1590,7 @@ func (service mockService) getImagesByDigestGQL(ctx context.Context, config sear
|
||||
digest string,
|
||||
) (*imageListStructForDigestGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForDigestGQL{}
|
||||
imageListGQLResponse.Data.ImageList = []imageStruct{
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
{
|
||||
RepoName: "randomimageName",
|
||||
Tag: "tag",
|
||||
@@ -1610,14 +1610,14 @@ func (service mockService) getImagesByCveIDGQL(ctx context.Context, config searc
|
||||
imagesForCve := &imagesForCve{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
ImageList []imageStruct `json:"ImageListForCVE"` //nolint:tagliatelle
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle
|
||||
}{},
|
||||
}
|
||||
|
||||
imagesForCve.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName("anImage")
|
||||
imagesForCve.Data.ImageList = []imageStruct{mockedImage}
|
||||
imagesForCve.Data.Results = []imageStruct{mockedImage}
|
||||
|
||||
return imagesForCve, nil
|
||||
}
|
||||
@@ -1628,14 +1628,14 @@ func (service mockService) getTagsForCVEGQL(ctx context.Context, config searchCo
|
||||
images := &imagesForCve{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
ImageList []imageStruct `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
}{},
|
||||
}
|
||||
|
||||
images.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName(imageName)
|
||||
images.Data.ImageList = []imageStruct{mockedImage}
|
||||
images.Data.Results = []imageStruct{mockedImage}
|
||||
|
||||
return images, nil
|
||||
}
|
||||
@@ -1646,14 +1646,14 @@ func (service mockService) getFixedTagsForCVEGQL(ctx context.Context, config sea
|
||||
fixedTags := &fixedTags{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
ImageList []imageStruct `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
}{},
|
||||
}
|
||||
|
||||
fixedTags.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName(imageName)
|
||||
fixedTags.Data.ImageList = []imageStruct{mockedImage}
|
||||
fixedTags.Data.Results = []imageStruct{mockedImage}
|
||||
|
||||
return fixedTags, nil
|
||||
}
|
||||
|
||||
+7
-7
@@ -188,7 +188,7 @@ func getImages(config searchConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return printResult(config, imageList.Data.ImageList)
|
||||
return printResult(config, imageList.Data.Results)
|
||||
}
|
||||
|
||||
type imagesByDigestSearcher struct{}
|
||||
@@ -241,7 +241,7 @@ func (search derivedImageListSearcherGQL) search(config searchConfig) (bool, err
|
||||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.ImageList.Results); err != nil {
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func (search baseImageListSearcherGQL) search(config searchConfig) (bool, error)
|
||||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.ImageList.Results); err != nil {
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ func (search imagesByDigestSearcherGQL) search(config searchConfig) (bool, error
|
||||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.ImageList); err != nil {
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ func (search imagesByCVEIDSearcherGQL) search(config searchConfig) (bool, error)
|
||||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.ImageList); err != nil {
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ func getTagsByCVE(config searchConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
imageList = fixedTags.Data.ImageList
|
||||
imageList = fixedTags.Data.Results
|
||||
} else {
|
||||
tags, err := config.searchService.getTagsForCVEGQL(ctx, config, username, password,
|
||||
*config.params["imageName"], *config.params["cveID"])
|
||||
@@ -561,7 +561,7 @@ func getTagsByCVE(config searchConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
imageList = tags.Data.ImageList
|
||||
imageList = tags.Data.Results
|
||||
}
|
||||
|
||||
return printResult(config, imageList)
|
||||
|
||||
+33
-29
@@ -126,8 +126,8 @@ func (service searchService) getBaseImageListGQL(ctx context.Context, config sea
|
||||
func (service searchService) getImagesGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
imageName string,
|
||||
) (*imageListStructGQL, error) {
|
||||
query := fmt.Sprintf(`{ImageList(repo: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest} IsSigned}
|
||||
query := fmt.Sprintf(`{ImageList(repo: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest} IsSigned}}
|
||||
}`,
|
||||
imageName)
|
||||
result := &imageListStructGQL{}
|
||||
@@ -144,8 +144,8 @@ func (service searchService) getImagesGQL(ctx context.Context, config searchConf
|
||||
func (service searchService) getImagesByDigestGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
digest string,
|
||||
) (*imageListStructForDigestGQL, error) {
|
||||
query := fmt.Sprintf(`{ImageListForDigest(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}
|
||||
query := fmt.Sprintf(`{ImageListForDigest(id: "%s") { Results{`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}}
|
||||
}`,
|
||||
digest)
|
||||
result := &imageListStructForDigestGQL{}
|
||||
@@ -162,8 +162,8 @@ func (service searchService) getImagesByDigestGQL(ctx context.Context, config se
|
||||
func (service searchService) getImagesByCveIDGQL(ctx context.Context, config searchConfig, username,
|
||||
password, cveID string,
|
||||
) (*imagesForCve, error) {
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}}
|
||||
}`,
|
||||
cveID)
|
||||
result := &imagesForCve{}
|
||||
@@ -199,8 +199,8 @@ func (service searchService) getCveByImageGQL(ctx context.Context, config search
|
||||
func (service searchService) getTagsForCVEGQL(ctx context.Context, config searchConfig,
|
||||
username, password, imageName, cveID string,
|
||||
) (*imagesForCve, error) {
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}}
|
||||
}`,
|
||||
cveID)
|
||||
result := &imagesForCve{}
|
||||
@@ -217,8 +217,8 @@ func (service searchService) getTagsForCVEGQL(ctx context.Context, config search
|
||||
func (service searchService) getFixedTagsForCVEGQL(ctx context.Context, config searchConfig,
|
||||
username, password, imageName, cveID string,
|
||||
) (*fixedTags, error) {
|
||||
query := fmt.Sprintf(`{ImageListWithCVEFixed(id: "%s", image: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}
|
||||
query := fmt.Sprintf(`{ImageListWithCVEFixed(id: "%s", image: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}}
|
||||
}`,
|
||||
cveID, imageName)
|
||||
|
||||
@@ -349,8 +349,8 @@ func (service searchService) getImagesByCveID(ctx context.Context, config search
|
||||
defer wtgrp.Done()
|
||||
defer close(rch)
|
||||
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}}
|
||||
}`,
|
||||
cvid)
|
||||
result := &imagesForCve{}
|
||||
@@ -387,7 +387,7 @@ func (service searchService) getImagesByCveID(ctx context.Context, config search
|
||||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.ImageList {
|
||||
for _, image := range result.Data.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, image.RepoName, image.Tag, rch, &localWg)
|
||||
@@ -402,8 +402,8 @@ func (service searchService) getImagesByDigest(ctx context.Context, config searc
|
||||
defer wtgrp.Done()
|
||||
defer close(rch)
|
||||
|
||||
query := fmt.Sprintf(`{ImageListForDigest(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}
|
||||
query := fmt.Sprintf(`{ImageListForDigest(id: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}}
|
||||
}`,
|
||||
digest)
|
||||
result := &imagesForDigest{}
|
||||
@@ -440,7 +440,7 @@ func (service searchService) getImagesByDigest(ctx context.Context, config searc
|
||||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.ImageList {
|
||||
for _, image := range result.Data.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, image.RepoName, image.Tag, rch, &localWg)
|
||||
@@ -455,8 +455,8 @@ func (service searchService) getImageByNameAndCVEID(ctx context.Context, config
|
||||
defer wtgrp.Done()
|
||||
defer close(rch)
|
||||
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}
|
||||
query := fmt.Sprintf(`{ImageListForCVE(id: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Size Layers {Size Digest}}}
|
||||
}`,
|
||||
cvid)
|
||||
result := &imagesForCve{}
|
||||
@@ -493,7 +493,7 @@ func (service searchService) getImageByNameAndCVEID(ctx context.Context, config
|
||||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.ImageList {
|
||||
for _, image := range result.Data.Results {
|
||||
if !strings.EqualFold(imageName, image.RepoName) {
|
||||
continue
|
||||
}
|
||||
@@ -566,8 +566,8 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
|
||||
defer wtgrp.Done()
|
||||
defer close(rch)
|
||||
|
||||
query := fmt.Sprintf(`{ImageListWithCVEFixed (id: "%s", image: "%s") {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}
|
||||
query := fmt.Sprintf(`{ImageListWithCVEFixed (id: "%s", image: "%s") { Results {`+`
|
||||
RepoName Tag Digest ConfigDigest Layers {Size Digest} Size}}
|
||||
}`,
|
||||
cvid, imageName)
|
||||
result := &fixedTags{}
|
||||
@@ -604,7 +604,7 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
|
||||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, img := range result.Data.ImageList {
|
||||
for _, img := range result.Data.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, imageName, img.Tag, rch, &localWg)
|
||||
@@ -844,17 +844,21 @@ func (cve cveResult) stringYAML() (string, error) {
|
||||
type fixedTags struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList []imageStruct `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imagesForCve struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList []imageStruct `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type PaginatedImagesResult struct {
|
||||
Results []imageStruct `json:"results"`
|
||||
}
|
||||
|
||||
type imageStruct struct {
|
||||
RepoName string `json:"repoName"`
|
||||
Tag string `json:"tag"`
|
||||
@@ -876,35 +880,35 @@ type BaseImageList struct {
|
||||
type imageListStructGQL struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList []imageStruct `json:"ImageList"` //nolint:tagliatelle
|
||||
PaginatedImagesResult `json:"ImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForDigestGQL struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList []imageStruct `json:"ImageListForDigest"` //nolint:tagliatelle
|
||||
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForDerivedImagesGQL struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList DerivedImageList `json:"DerivedImageList"` //nolint:tagliatelle
|
||||
PaginatedImagesResult `json:"DerivedImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForBaseImagesGQL struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList BaseImageList `json:"BaseImageList"` //nolint:tagliatelle
|
||||
PaginatedImagesResult `json:"BaseImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imagesForDigest struct {
|
||||
Errors []errorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
ImageList []imageStruct `json:"ImageListForDigest"` //nolint:tagliatelle // graphQL schema
|
||||
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user