mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
fix: removed duplicate structures from service.go and moved them to pkg/common (#1436)
Signed-off-by: Ana-Roberta Lisca <ana.kagome@yahoo.com>
This commit is contained in:
parent
4970f8814d
commit
6a7035c599
18 changed files with 707 additions and 721 deletions
|
@ -217,6 +217,8 @@ func (p *requestsPool) doJob(ctx context.Context, job *httpJob) {
|
|||
p.outputCh <- stringResult{"", err}
|
||||
}
|
||||
|
||||
verbose := *job.config.verbose
|
||||
|
||||
switch header.Get("Content-Type") {
|
||||
case ispec.MediaTypeImageManifest:
|
||||
image, err := fetchImageManifestStruct(ctx, job)
|
||||
|
@ -230,7 +232,7 @@ func (p *requestsPool) doJob(ctx context.Context, job *httpJob) {
|
|||
}
|
||||
platformStr := getPlatformStr(image.Manifests[0].Platform)
|
||||
|
||||
str, err := image.string(*job.config.outputFormat, len(job.imageName), len(job.tagName), len(platformStr))
|
||||
str, err := image.string(*job.config.outputFormat, len(job.imageName), len(job.tagName), len(platformStr), verbose)
|
||||
if err != nil {
|
||||
if isContextDone(ctx) {
|
||||
return
|
||||
|
@ -258,7 +260,7 @@ func (p *requestsPool) doJob(ctx context.Context, job *httpJob) {
|
|||
|
||||
platformStr := getPlatformStr(image.Manifests[0].Platform)
|
||||
|
||||
str, err := image.string(*job.config.outputFormat, len(job.imageName), len(job.tagName), len(platformStr))
|
||||
str, err := image.string(*job.config.outputFormat, len(job.imageName), len(job.tagName), len(platformStr), verbose)
|
||||
if err != nil {
|
||||
if isContextDone(ctx) {
|
||||
return
|
||||
|
@ -300,7 +302,7 @@ func fetchImageIndexStruct(ctx context.Context, job *httpJob) (*imageStruct, err
|
|||
|
||||
imageSize := indexSize
|
||||
|
||||
manifestList := make([]manifestStruct, 0, len(indexContent.Manifests))
|
||||
manifestList := make([]common.ManifestSummary, 0, len(indexContent.Manifests))
|
||||
|
||||
for _, manifestDescriptor := range indexContent.Manifests {
|
||||
manifest, err := fetchManifestStruct(ctx, job.imageName, manifestDescriptor.Digest.String(),
|
||||
|
@ -312,7 +314,7 @@ func fetchImageIndexStruct(ctx context.Context, job *httpJob) (*imageStruct, err
|
|||
imageSize += int64(atoiWithDefault(manifest.Size, 0))
|
||||
|
||||
if manifestDescriptor.Platform != nil {
|
||||
manifest.Platform = platform{
|
||||
manifest.Platform = common.Platform{
|
||||
Os: manifestDescriptor.Platform.OS,
|
||||
Arch: manifestDescriptor.Platform.Architecture,
|
||||
Variant: manifestDescriptor.Platform.Variant,
|
||||
|
@ -333,7 +335,6 @@ func fetchImageIndexStruct(ctx context.Context, job *httpJob) (*imageStruct, err
|
|||
Manifests: manifestList,
|
||||
Size: strconv.FormatInt(imageSize, 10),
|
||||
IsSigned: isIndexSigned,
|
||||
verbose: *job.config.verbose,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -357,18 +358,17 @@ func fetchImageManifestStruct(ctx context.Context, job *httpJob) (*imageStruct,
|
|||
Tag: job.tagName,
|
||||
Digest: manifest.Digest,
|
||||
MediaType: ispec.MediaTypeImageManifest,
|
||||
Manifests: []manifestStruct{
|
||||
Manifests: []common.ManifestSummary{
|
||||
manifest,
|
||||
},
|
||||
Size: manifest.Size,
|
||||
IsSigned: manifest.IsSigned,
|
||||
verbose: *job.config.verbose,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func fetchManifestStruct(ctx context.Context, repo, manifestReference string, searchConf searchConfig,
|
||||
username, password string,
|
||||
) (manifestStruct, error) {
|
||||
) (common.ManifestSummary, error) {
|
||||
manifestResp := ispec.Manifest{}
|
||||
|
||||
URL := fmt.Sprintf("%s/v2/%s/manifests/%s",
|
||||
|
@ -378,10 +378,10 @@ func fetchManifestStruct(ctx context.Context, repo, manifestReference string, se
|
|||
*searchConf.verifyTLS, *searchConf.debug, &manifestResp, searchConf.resultWriter)
|
||||
if err != nil {
|
||||
if isContextDone(ctx) {
|
||||
return manifestStruct{}, context.Canceled
|
||||
return common.ManifestSummary{}, context.Canceled
|
||||
}
|
||||
|
||||
return manifestStruct{}, err
|
||||
return common.ManifestSummary{}, err
|
||||
}
|
||||
|
||||
manifestDigest := header.Get("docker-content-digest")
|
||||
|
@ -390,10 +390,10 @@ func fetchManifestStruct(ctx context.Context, repo, manifestReference string, se
|
|||
configContent, err := fetchConfig(ctx, repo, configDigest, searchConf, username, password)
|
||||
if err != nil {
|
||||
if isContextDone(ctx) {
|
||||
return manifestStruct{}, context.Canceled
|
||||
return common.ManifestSummary{}, context.Canceled
|
||||
}
|
||||
|
||||
return manifestStruct{}, err
|
||||
return common.ManifestSummary{}, err
|
||||
}
|
||||
|
||||
opSys := ""
|
||||
|
@ -420,7 +420,7 @@ func fetchManifestStruct(ctx context.Context, repo, manifestReference string, se
|
|||
|
||||
manifestSize, err := strconv.ParseInt(header.Get("Content-Length"), 10, 64)
|
||||
if err != nil {
|
||||
return manifestStruct{}, err
|
||||
return common.ManifestSummary{}, err
|
||||
}
|
||||
|
||||
var imageSize int64
|
||||
|
@ -428,15 +428,15 @@ func fetchManifestStruct(ctx context.Context, repo, manifestReference string, se
|
|||
imageSize += manifestResp.Config.Size
|
||||
imageSize += manifestSize
|
||||
|
||||
layers := []layer{}
|
||||
layers := []common.LayerSummary{}
|
||||
|
||||
for _, entry := range manifestResp.Layers {
|
||||
imageSize += entry.Size
|
||||
|
||||
layers = append(
|
||||
layers,
|
||||
layer{
|
||||
Size: entry.Size,
|
||||
common.LayerSummary{
|
||||
Size: fmt.Sprintf("%v", entry.Size),
|
||||
Digest: entry.Digest.String(),
|
||||
},
|
||||
)
|
||||
|
@ -445,11 +445,11 @@ func fetchManifestStruct(ctx context.Context, repo, manifestReference string, se
|
|||
isSigned := isCosignSigned(ctx, repo, manifestDigest, searchConf, username, password) ||
|
||||
isNotationSigned(ctx, repo, manifestDigest, searchConf, username, password)
|
||||
|
||||
return manifestStruct{
|
||||
return common.ManifestSummary{
|
||||
ConfigDigest: configDigest,
|
||||
Digest: manifestDigest,
|
||||
Layers: layers,
|
||||
Platform: platform{Os: opSys, Arch: arch, Variant: variant},
|
||||
Platform: common.Platform{Os: opSys, Arch: arch, Variant: variant},
|
||||
Size: strconv.FormatInt(imageSize, 10),
|
||||
IsSigned: isSigned,
|
||||
}, nil
|
||||
|
|
|
@ -25,7 +25,7 @@ type schemaList struct {
|
|||
} `json:"queryType"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"__schema"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Errors []common.ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
func containsGQLQuery(queryList []field, query string) bool {
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
zotErrors "zotregistry.io/zot/errors"
|
||||
"zotregistry.io/zot/pkg/api"
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
extconf "zotregistry.io/zot/pkg/extensions/config"
|
||||
"zotregistry.io/zot/pkg/test"
|
||||
)
|
||||
|
@ -753,13 +754,18 @@ func TestOutputFormat(t *testing.T) {
|
|||
space := regexp.MustCompile(`\s+`)
|
||||
str := space.ReplaceAllString(buff.String(), " ")
|
||||
So(strings.TrimSpace(str), ShouldEqual, `{ "repoName": "dummyImageName", "tag": "tag", `+
|
||||
`"Manifests": [ { "configDigest": "sha256:4c10985c40365538426f2ba8cf0c21384a7769be502a550dcc0601b3736625e0", `+
|
||||
`"digest": "sha256:6e2f80bf9cfaabad474fbaf8ad68fdb652f776ea80b63492ecca404e5f6446a6", `+
|
||||
`"layers": [ { "size": "0", "digest": "sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6" } ], `+ //nolint:lll
|
||||
`"platform": { "os": "os", "arch": "arch", "variant": "" }, `+
|
||||
`"size": "123445", "isSigned": false } ], `+
|
||||
`"size": "123445", "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", `+
|
||||
`"mediaType": "application/vnd.oci.image.manifest.v1+json", "isSigned": false }`)
|
||||
`"digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", `+
|
||||
`"mediaType": "application/vnd.oci.image.manifest.v1+json", `+
|
||||
`"manifests": [ { "digest": "sha256:6e2f80bf9cfaabad474fbaf8ad68fdb652f776ea80b63492ecca404e5f6446a6", `+
|
||||
`"configDigest": "sha256:4c10985c40365538426f2ba8cf0c21384a7769be502a550dcc0601b3736625e0", `+
|
||||
`"lastUpdated": "0001-01-01T00:00:00Z", "size": "123445", "platform": { "os": "os", "arch": "arch", `+
|
||||
`"variant": "" }, "isSigned": false, "downloadCount": 0, `+
|
||||
`"layers": [ { "size": "", "digest": "sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6", `+
|
||||
`"score": 0 } ], "history": null, "vulnerabilities": { "maxSeverity": "", "count": 0 }, `+
|
||||
`"referrers": null, "artifactType": "" } ], "size": "123445", `+
|
||||
`"downloadCount": 0, "lastUpdated": "0001-01-01T00:00:00Z", "description": "", "isSigned": false, "licenses": "", `+
|
||||
`"labels": "", "title": "", "source": "", "documentation": "", "authors": "", "vendor": "", `+
|
||||
`"vulnerabilities": { "maxSeverity": "", "count": 0 }, "referrers": null }`)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
|
@ -779,14 +785,18 @@ func TestOutputFormat(t *testing.T) {
|
|||
strings.TrimSpace(str),
|
||||
ShouldEqual,
|
||||
`reponame: dummyImageName tag: tag `+
|
||||
`manifests: - `+
|
||||
`configdigest: sha256:4c10985c40365538426f2ba8cf0c21384a7769be502a550dcc0601b3736625e0 `+
|
||||
`digest: sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 `+
|
||||
`mediatype: application/vnd.oci.image.manifest.v1+json manifests: - `+
|
||||
`digest: sha256:6e2f80bf9cfaabad474fbaf8ad68fdb652f776ea80b63492ecca404e5f6446a6 `+
|
||||
`layers: - size: 0 digest: sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6 `+
|
||||
`platform: os: os arch: arch variant: "" `+
|
||||
`size: "123445" issigned: false `+
|
||||
`size: "123445" digest: sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 `+
|
||||
`mediatype: application/vnd.oci.image.manifest.v1+json issigned: false`,
|
||||
`configdigest: sha256:4c10985c40365538426f2ba8cf0c21384a7769be502a550dcc0601b3736625e0 `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z size: "123445" platform: os: os arch: arch variant: "" `+
|
||||
`issigned: false downloadcount: 0 layers: - size: "" `+
|
||||
`digest: sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6 score: 0 `+
|
||||
`history: [] vulnerabilities: maxseverity: "" count: 0 referrers: [] artifacttype: "" `+
|
||||
`size: "123445" downloadcount: 0 `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z description: "" issigned: false licenses: "" labels: "" `+
|
||||
`title: "" source: "" documentation: "" authors: "" vendor: "" vulnerabilities: maxseverity: "" `+
|
||||
`count: 0 referrers: []`,
|
||||
)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
|
@ -809,14 +819,18 @@ func TestOutputFormat(t *testing.T) {
|
|||
strings.TrimSpace(str),
|
||||
ShouldEqual,
|
||||
`reponame: dummyImageName tag: tag `+
|
||||
`manifests: - `+
|
||||
`digest: sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 `+
|
||||
`mediatype: application/vnd.oci.image.manifest.v1+json `+
|
||||
`manifests: - digest: sha256:6e2f80bf9cfaabad474fbaf8ad68fdb652f776ea80b63492ecca404e5f6446a6 `+
|
||||
`configdigest: sha256:4c10985c40365538426f2ba8cf0c21384a7769be502a550dcc0601b3736625e0 `+
|
||||
`digest: sha256:6e2f80bf9cfaabad474fbaf8ad68fdb652f776ea80b63492ecca404e5f6446a6 `+
|
||||
`layers: - size: 0 digest: sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6 `+
|
||||
`platform: os: os arch: arch variant: "" `+
|
||||
`size: "123445" issigned: false `+
|
||||
`size: "123445" digest: sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 `+
|
||||
`mediatype: application/vnd.oci.image.manifest.v1+json issigned: false`,
|
||||
`lastupdated: 0001-01-01T00:00:00Z size: "123445" platform: os: os arch: arch variant: "" `+
|
||||
`issigned: false downloadcount: 0 layers: - size: "" `+
|
||||
`digest: sha256:c122a146f0d02349be211bb95cc2530f4a5793f96edbdfa00860f741e5d8c0e6 score: 0 `+
|
||||
`history: [] vulnerabilities: maxseverity: "" count: 0 referrers: [] artifacttype: "" `+
|
||||
`size: "123445" downloadcount: 0 `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z description: "" issigned: false licenses: "" labels: "" `+
|
||||
`title: "" source: "" documentation: "" authors: "" vendor: "" vulnerabilities: maxseverity: `+
|
||||
`"" count: 0 referrers: []`,
|
||||
)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
@ -1698,18 +1712,18 @@ func (service mockService) getRepos(ctx context.Context, config searchConfig, us
|
|||
|
||||
func (service mockService) getDerivedImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
derivedImage string,
|
||||
) (*imageListStructForDerivedImagesGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForDerivedImagesGQL{}
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
) (*common.DerivedImageListResponse, error) {
|
||||
imageListGQLResponse := &common.DerivedImageListResponse{}
|
||||
imageListGQLResponse.DerivedImageList.Results = []common.ImageSummary{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
Manifests: []manifestStruct{
|
||||
Manifests: []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Size: "123445",
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
},
|
||||
},
|
||||
Size: "123445",
|
||||
|
@ -1721,18 +1735,18 @@ func (service mockService) getDerivedImageListGQL(ctx context.Context, config se
|
|||
|
||||
func (service mockService) getBaseImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
derivedImage string,
|
||||
) (*imageListStructForBaseImagesGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForBaseImagesGQL{}
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
) (*common.BaseImageListResponse, error) {
|
||||
imageListGQLResponse := &common.BaseImageListResponse{}
|
||||
imageListGQLResponse.BaseImageList.Results = []common.ImageSummary{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
Manifests: []manifestStruct{
|
||||
Manifests: []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Size: "123445",
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
},
|
||||
},
|
||||
Size: "123445",
|
||||
|
@ -1744,20 +1758,20 @@ func (service mockService) getBaseImageListGQL(ctx context.Context, config searc
|
|||
|
||||
func (service mockService) getImagesGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
imageName string,
|
||||
) (*imageListStructGQL, error) {
|
||||
imageListGQLResponse := &imageListStructGQL{}
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
) (*common.ImageListResponse, error) {
|
||||
imageListGQLResponse := &common.ImageListResponse{}
|
||||
imageListGQLResponse.PaginatedImagesResult.Results = []common.ImageSummary{
|
||||
{
|
||||
RepoName: "dummyImageName",
|
||||
Tag: "tag",
|
||||
MediaType: ispec.MediaTypeImageManifest,
|
||||
Digest: godigest.FromString("test").String(),
|
||||
Manifests: []manifestStruct{
|
||||
Manifests: []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Size: "123445",
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
},
|
||||
},
|
||||
Size: "123445",
|
||||
|
@ -1769,19 +1783,19 @@ func (service mockService) getImagesGQL(ctx context.Context, config searchConfig
|
|||
|
||||
func (service mockService) getImagesByDigestGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
digest string,
|
||||
) (*imageListStructForDigestGQL, error) {
|
||||
imageListGQLResponse := &imageListStructForDigestGQL{}
|
||||
imageListGQLResponse.Data.Results = []imageStruct{
|
||||
) (*common.ImagesForDigest, error) {
|
||||
imageListGQLResponse := &common.ImagesForDigest{}
|
||||
imageListGQLResponse.Results = []common.ImageSummary{
|
||||
{
|
||||
RepoName: "randomimageName",
|
||||
Tag: "tag",
|
||||
MediaType: ispec.MediaTypeImageManifest,
|
||||
Digest: godigest.FromString("test").String(),
|
||||
Manifests: []manifestStruct{
|
||||
Manifests: []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Size: "123445",
|
||||
},
|
||||
},
|
||||
|
@ -1794,54 +1808,54 @@ func (service mockService) getImagesByDigestGQL(ctx context.Context, config sear
|
|||
|
||||
func (service mockService) getImagesByCveIDGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
digest string,
|
||||
) (*imagesForCve, error) {
|
||||
imagesForCve := &imagesForCve{
|
||||
) (*common.ImagesForCve, error) {
|
||||
imagesForCve := &common.ImagesForCve{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle
|
||||
ImagesForCVEList: struct {
|
||||
common.PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle
|
||||
}{},
|
||||
}
|
||||
|
||||
imagesForCve.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName("anImage")
|
||||
imagesForCve.Data.Results = []imageStruct{mockedImage}
|
||||
imagesForCve.Results = []common.ImageSummary{common.ImageSummary(mockedImage)}
|
||||
|
||||
return imagesForCve, nil
|
||||
}
|
||||
|
||||
func (service mockService) getTagsForCVEGQL(ctx context.Context, config searchConfig, username, password,
|
||||
imageName, cveID string,
|
||||
) (*imagesForCve, error) {
|
||||
images := &imagesForCve{
|
||||
) (*common.ImagesForCve, error) {
|
||||
images := &common.ImagesForCve{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
ImagesForCVEList: struct {
|
||||
common.PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
}{},
|
||||
}
|
||||
|
||||
images.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName(imageName)
|
||||
images.Data.Results = []imageStruct{mockedImage}
|
||||
images.Results = []common.ImageSummary{common.ImageSummary(mockedImage)}
|
||||
|
||||
return images, nil
|
||||
}
|
||||
|
||||
func (service mockService) getFixedTagsForCVEGQL(ctx context.Context, config searchConfig, username, password,
|
||||
imageName, cveID string,
|
||||
) (*fixedTags, error) {
|
||||
fixedTags := &fixedTags{
|
||||
) (*common.FixedTags, error) {
|
||||
fixedTags := &common.FixedTags{
|
||||
Errors: nil,
|
||||
Data: struct {
|
||||
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
ImageListWithCVEFixed: struct {
|
||||
common.PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
}{},
|
||||
}
|
||||
|
||||
fixedTags.Errors = nil
|
||||
|
||||
mockedImage := service.getMockedImageByName(imageName)
|
||||
fixedTags.Data.Results = []imageStruct{mockedImage}
|
||||
fixedTags.Results = []common.ImageSummary{common.ImageSummary(mockedImage)}
|
||||
|
||||
return fixedTags, nil
|
||||
}
|
||||
|
@ -1879,11 +1893,11 @@ func (service mockService) getMockedImageByName(imageName string) imageStruct {
|
|||
image := imageStruct{}
|
||||
image.RepoName = imageName
|
||||
image.Tag = "tag"
|
||||
image.Manifests = []manifestStruct{
|
||||
image.Manifests = []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Size: "123445",
|
||||
},
|
||||
}
|
||||
|
@ -1903,18 +1917,18 @@ func (service mockService) getAllImages(ctx context.Context, config searchConfig
|
|||
image.Tag = "tag"
|
||||
image.Digest = godigest.FromString("test").String()
|
||||
image.MediaType = ispec.MediaTypeImageManifest
|
||||
image.Manifests = []manifestStruct{
|
||||
image.Manifests = []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Size: "123445",
|
||||
Platform: platform{Os: "os", Arch: "arch"},
|
||||
Platform: common.Platform{Os: "os", Arch: "arch"},
|
||||
},
|
||||
}
|
||||
image.Size = "123445"
|
||||
|
||||
str, err := image.string(*config.outputFormat, len(image.RepoName), len(image.Tag), len("os/Arch"))
|
||||
str, err := image.string(*config.outputFormat, len(image.RepoName), len(image.Tag), len("os/Arch"), *config.verbose)
|
||||
if err != nil {
|
||||
channel <- stringResult{"", err}
|
||||
|
||||
|
@ -1935,18 +1949,18 @@ func (service mockService) getImageByName(ctx context.Context, config searchConf
|
|||
image.Tag = "tag"
|
||||
image.Digest = godigest.FromString("test").String()
|
||||
image.MediaType = ispec.MediaTypeImageManifest
|
||||
image.Manifests = []manifestStruct{
|
||||
image.Manifests = []common.ManifestSummary{
|
||||
{
|
||||
Digest: godigest.FromString("Digest").String(),
|
||||
ConfigDigest: godigest.FromString("ConfigDigest").String(),
|
||||
Layers: []layer{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Layers: []common.LayerSummary{{Digest: godigest.FromString("LayerDigest").String()}},
|
||||
Size: "123445",
|
||||
Platform: platform{Os: "os", Arch: "arch"},
|
||||
Platform: common.Platform{Os: "os", Arch: "arch"},
|
||||
},
|
||||
}
|
||||
image.Size = "123445"
|
||||
|
||||
str, err := image.string(*config.outputFormat, len(image.RepoName), len(image.Tag), len("os/Arch"))
|
||||
str, err := image.string(*config.outputFormat, len(image.RepoName), len(image.Tag), len("os/Arch"), *config.verbose)
|
||||
if err != nil {
|
||||
channel <- stringResult{"", err}
|
||||
|
||||
|
|
|
@ -188,7 +188,13 @@ func getImages(config searchConfig) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return printResult(config, imageList.Data.Results)
|
||||
imageListData := []imageStruct{}
|
||||
|
||||
for _, image := range imageList.Results {
|
||||
imageListData = append(imageListData, imageStruct(image))
|
||||
}
|
||||
|
||||
return printResult(config, imageListData)
|
||||
}
|
||||
|
||||
type imagesByDigestSearcher struct{}
|
||||
|
@ -241,7 +247,13 @@ func (search derivedImageListSearcherGQL) search(config searchConfig) (bool, err
|
|||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
imageListData := []imageStruct{}
|
||||
|
||||
for _, image := range imageList.DerivedImageList.Results {
|
||||
imageListData = append(imageListData, imageStruct(image))
|
||||
}
|
||||
|
||||
if err := printResult(config, imageListData); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
|
@ -266,7 +278,13 @@ func (search baseImageListSearcherGQL) search(config searchConfig) (bool, error)
|
|||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
imageListData := []imageStruct{}
|
||||
|
||||
for _, image := range imageList.BaseImageList.Results {
|
||||
imageListData = append(imageListData, imageStruct(image))
|
||||
}
|
||||
|
||||
if err := printResult(config, imageListData); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
|
@ -292,7 +310,13 @@ func (search imagesByDigestSearcherGQL) search(config searchConfig) (bool, error
|
|||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
imageListData := []imageStruct{}
|
||||
|
||||
for _, image := range imageList.Results {
|
||||
imageListData = append(imageListData, imageStruct(image))
|
||||
}
|
||||
|
||||
if err := printResult(config, imageListData); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
|
@ -431,7 +455,13 @@ func (search imagesByCVEIDSearcherGQL) search(config searchConfig) (bool, error)
|
|||
return true, err
|
||||
}
|
||||
|
||||
if err := printResult(config, imageList.Data.Results); err != nil {
|
||||
imageListData := []imageStruct{}
|
||||
|
||||
for _, image := range imageList.Results {
|
||||
imageListData = append(imageListData, imageStruct(image))
|
||||
}
|
||||
|
||||
if err := printResult(config, imageListData); err != nil {
|
||||
return true, err
|
||||
}
|
||||
|
||||
|
@ -557,7 +587,9 @@ func getTagsByCVE(config searchConfig) error {
|
|||
return err
|
||||
}
|
||||
|
||||
imageList = fixedTags.Data.Results
|
||||
for _, image := range fixedTags.Results {
|
||||
imageList = append(imageList, imageStruct(image))
|
||||
}
|
||||
} else {
|
||||
tags, err := config.searchService.getTagsForCVEGQL(ctx, config, username, password,
|
||||
*config.params["imageName"], *config.params["cveID"])
|
||||
|
@ -565,7 +597,10 @@ func getTagsByCVE(config searchConfig) error {
|
|||
return err
|
||||
}
|
||||
|
||||
imageList = tags.Data.Results
|
||||
imageList = nil
|
||||
for _, image := range tags.Results {
|
||||
imageList = append(imageList, imageStruct(image))
|
||||
}
|
||||
}
|
||||
|
||||
return printResult(config, imageList)
|
||||
|
@ -798,9 +833,9 @@ func printResult(config searchConfig, imageList []imageStruct) error {
|
|||
|
||||
for i := range imageList {
|
||||
img := imageList[i]
|
||||
img.verbose = *config.verbose
|
||||
verbose := *config.verbose
|
||||
|
||||
out, err := img.string(*config.outputFormat, maxImgNameLen, maxTagLen, maxPlatformLen)
|
||||
out, err := img.string(*config.outputFormat, maxImgNameLen, maxTagLen, maxPlatformLen, verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -27,21 +27,21 @@ import (
|
|||
|
||||
type SearchService interface { //nolint:interfacebloat
|
||||
getImagesGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
imageName string) (*imageListStructGQL, error)
|
||||
imageName string) (*common.ImageListResponse, error)
|
||||
getImagesByDigestGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
digest string) (*imageListStructForDigestGQL, error)
|
||||
digest string) (*common.ImagesForDigest, error)
|
||||
getCveByImageGQL(ctx context.Context, config searchConfig, username, password,
|
||||
imageName string, searchedCVE string) (*cveResult, error)
|
||||
getImagesByCveIDGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
digest string) (*imagesForCve, error)
|
||||
digest string) (*common.ImagesForCve, error)
|
||||
getTagsForCVEGQL(ctx context.Context, config searchConfig, username, password, imageName,
|
||||
cveID string) (*imagesForCve, error)
|
||||
cveID string) (*common.ImagesForCve, error)
|
||||
getFixedTagsForCVEGQL(ctx context.Context, config searchConfig, username, password, imageName,
|
||||
cveID string) (*fixedTags, error)
|
||||
cveID string) (*common.FixedTags, error)
|
||||
getDerivedImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
derivedImage string) (*imageListStructForDerivedImagesGQL, error)
|
||||
derivedImage string) (*common.DerivedImageListResponse, error)
|
||||
getBaseImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
baseImage string) (*imageListStructForBaseImagesGQL, error)
|
||||
baseImage string) (*common.BaseImageListResponse, error)
|
||||
|
||||
getAllImages(ctx context.Context, config searchConfig, username, password string,
|
||||
channel chan stringResult, wtgrp *sync.WaitGroup)
|
||||
|
@ -69,7 +69,7 @@ func NewSearchService() SearchService {
|
|||
|
||||
func (service searchService) getDerivedImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
derivedImage string,
|
||||
) (*imageListStructForDerivedImagesGQL, error) {
|
||||
) (*common.DerivedImageListResponse, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
DerivedImageList(image:"%s"){
|
||||
|
@ -93,7 +93,7 @@ func (service searchService) getDerivedImageListGQL(ctx context.Context, config
|
|||
}
|
||||
}`, derivedImage)
|
||||
|
||||
result := &imageListStructForDerivedImagesGQL{}
|
||||
result := &common.DerivedImageListResponse{}
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
if errResult := checkResultGraphQLQuery(ctx, err, result.Errors); errResult != nil {
|
||||
|
@ -105,7 +105,7 @@ func (service searchService) getDerivedImageListGQL(ctx context.Context, config
|
|||
|
||||
func (service searchService) getBaseImageListGQL(ctx context.Context, config searchConfig, username, password string,
|
||||
baseImage string,
|
||||
) (*imageListStructForBaseImagesGQL, error) {
|
||||
) (*common.BaseImageListResponse, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
BaseImageList(image:"%s"){
|
||||
|
@ -129,7 +129,7 @@ func (service searchService) getBaseImageListGQL(ctx context.Context, config sea
|
|||
}
|
||||
}`, baseImage)
|
||||
|
||||
result := &imageListStructForBaseImagesGQL{}
|
||||
result := &common.BaseImageListResponse{}
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
if errResult := checkResultGraphQLQuery(ctx, err, result.Errors); errResult != nil {
|
||||
|
@ -141,7 +141,7 @@ 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) {
|
||||
) (*common.ImageListResponse, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
ImageList(repo: "%s") {
|
||||
|
@ -163,7 +163,7 @@ func (service searchService) getImagesGQL(ctx context.Context, config searchConf
|
|||
}
|
||||
}`,
|
||||
imageName)
|
||||
result := &imageListStructGQL{}
|
||||
result := &common.ImageListResponse{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
|
@ -176,7 +176,7 @@ 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) {
|
||||
) (*common.ImagesForDigest, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
ImageListForDigest(id: "%s") {
|
||||
|
@ -197,7 +197,7 @@ func (service searchService) getImagesByDigestGQL(ctx context.Context, config se
|
|||
}
|
||||
}`,
|
||||
digest)
|
||||
result := &imageListStructForDigestGQL{}
|
||||
result := &common.ImagesForDigest{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
|
@ -210,7 +210,7 @@ func (service searchService) getImagesByDigestGQL(ctx context.Context, config se
|
|||
|
||||
func (service searchService) getImagesByCveIDGQL(ctx context.Context, config searchConfig, username,
|
||||
password, cveID string,
|
||||
) (*imagesForCve, error) {
|
||||
) (*common.ImagesForCve, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
ImageListForCVE(id: "%s") {
|
||||
|
@ -231,7 +231,7 @@ func (service searchService) getImagesByCveIDGQL(ctx context.Context, config sea
|
|||
}
|
||||
}`,
|
||||
cveID)
|
||||
result := &imagesForCve{}
|
||||
result := &common.ImagesForCve{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
|
@ -263,7 +263,7 @@ 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) {
|
||||
) (*common.ImagesForCve, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
ImageListForCVE(id: "%s") {
|
||||
|
@ -283,7 +283,7 @@ func (service searchService) getTagsForCVEGQL(ctx context.Context, config search
|
|||
}
|
||||
}`,
|
||||
cveID)
|
||||
result := &imagesForCve{}
|
||||
result := &common.ImagesForCve{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
|
@ -296,7 +296,7 @@ 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) {
|
||||
) (*common.FixedTags, error) {
|
||||
query := fmt.Sprintf(`
|
||||
{
|
||||
ImageListWithCVEFixed(id: "%s", image: "%s") {
|
||||
|
@ -317,7 +317,7 @@ func (service searchService) getFixedTagsForCVEGQL(ctx context.Context, config s
|
|||
}`,
|
||||
cveID, imageName)
|
||||
|
||||
result := &fixedTags{}
|
||||
result := &common.FixedTags{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
|
||||
|
@ -464,7 +464,7 @@ func (service searchService) getImagesByCveID(ctx context.Context, config search
|
|||
}`,
|
||||
cvid)
|
||||
|
||||
result := &imagesForCve{}
|
||||
result := &common.ImagesForCve{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
if err != nil {
|
||||
|
@ -498,7 +498,7 @@ func (service searchService) getImagesByCveID(ctx context.Context, config search
|
|||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.Results {
|
||||
for _, image := range result.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, image.RepoName, image.Tag, rch, &localWg)
|
||||
|
@ -533,7 +533,7 @@ func (service searchService) getImagesByDigest(ctx context.Context, config searc
|
|||
}`,
|
||||
digest)
|
||||
|
||||
result := &imagesForDigest{}
|
||||
result := &common.ImagesForDigest{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
if err != nil {
|
||||
|
@ -567,7 +567,7 @@ func (service searchService) getImagesByDigest(ctx context.Context, config searc
|
|||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.Results {
|
||||
for _, image := range result.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, image.RepoName, image.Tag, rch, &localWg)
|
||||
|
@ -602,7 +602,7 @@ func (service searchService) getImageByNameAndCVEID(ctx context.Context, config
|
|||
}`,
|
||||
cvid)
|
||||
|
||||
result := &imagesForCve{}
|
||||
result := &common.ImagesForCve{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
if err != nil {
|
||||
|
@ -636,7 +636,7 @@ func (service searchService) getImageByNameAndCVEID(ctx context.Context, config
|
|||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, image := range result.Data.Results {
|
||||
for _, image := range result.Results {
|
||||
if !strings.EqualFold(imageName, image.RepoName) {
|
||||
continue
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
|
|||
}
|
||||
}`, cvid, imageName)
|
||||
|
||||
result := &fixedTags{}
|
||||
result := &common.FixedTags{}
|
||||
|
||||
err := service.makeGraphQLQuery(ctx, config, username, password, query, result)
|
||||
if err != nil {
|
||||
|
@ -762,7 +762,7 @@ func (service searchService) getFixedTagsForCVE(ctx context.Context, config sear
|
|||
|
||||
go rlim.startRateLimiter(ctx)
|
||||
|
||||
for _, img := range result.Data.Results {
|
||||
for _, img := range result.Results {
|
||||
localWg.Add(1)
|
||||
|
||||
go addManifestCallToPool(ctx, config, rlim, username, password, imageName, img.Tag, rch, &localWg)
|
||||
|
@ -844,7 +844,7 @@ func (service searchService) makeGraphQLQuery(ctx context.Context,
|
|||
return nil
|
||||
}
|
||||
|
||||
func checkResultGraphQLQuery(ctx context.Context, err error, resultErrors []common.ErrorGraphQL,
|
||||
func checkResultGraphQLQuery(ctx context.Context, err error, resultErrors []common.ErrorGQL,
|
||||
) error {
|
||||
if err != nil {
|
||||
if isContextDone(ctx) {
|
||||
|
@ -900,8 +900,8 @@ func addManifestCallToPool(ctx context.Context, config searchConfig, pool *reque
|
|||
}
|
||||
|
||||
type cveResult struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data cveData `json:"data"`
|
||||
Errors []common.ErrorGQL `json:"errors"`
|
||||
Data cveData `json:"data"`
|
||||
}
|
||||
|
||||
type tagListResp struct {
|
||||
|
@ -991,101 +991,12 @@ func (cve cveResult) stringYAML() (string, error) {
|
|||
return string(body), nil
|
||||
}
|
||||
|
||||
type fixedTags struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
}
|
||||
type imageStruct common.ImageSummary
|
||||
|
||||
type imagesForCve struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
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"`
|
||||
Manifests []manifestStruct
|
||||
Size string `json:"size"`
|
||||
Digest string `json:"digest"`
|
||||
MediaType string `json:"mediaType"`
|
||||
IsSigned bool `json:"isSigned"`
|
||||
verbose bool
|
||||
}
|
||||
|
||||
type manifestStruct struct {
|
||||
ConfigDigest string `json:"configDigest"`
|
||||
Digest string `json:"digest"`
|
||||
Layers []layer `json:"layers"`
|
||||
Platform platform `json:"platform"`
|
||||
Size string `json:"size"`
|
||||
IsSigned bool `json:"isSigned"`
|
||||
}
|
||||
|
||||
type platform struct {
|
||||
Os string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
Variant string `json:"variant"`
|
||||
}
|
||||
|
||||
type DerivedImageList struct {
|
||||
Results []imageStruct `json:"results"`
|
||||
}
|
||||
type BaseImageList struct {
|
||||
Results []imageStruct `json:"results"`
|
||||
}
|
||||
|
||||
type imageListStructGQL struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"ImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForDigestGQL struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForDerivedImagesGQL struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"DerivedImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imageListStructForBaseImagesGQL struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"BaseImageList"` //nolint:tagliatelle
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type imagesForDigest struct {
|
||||
Errors []common.ErrorGraphQL `json:"errors"`
|
||||
Data struct {
|
||||
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle // graphQL schema
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type layer struct {
|
||||
Size int64 `json:"size,string"`
|
||||
Digest string `json:"digest"`
|
||||
}
|
||||
|
||||
func (img imageStruct) string(format string, maxImgNameLen, maxTagLen, maxPlatformLen int) (string, error) {
|
||||
func (img imageStruct) string(format string, maxImgNameLen, maxTagLen, maxPlatformLen int, verbose bool) (string, error) { //nolint: lll
|
||||
switch strings.ToLower(format) {
|
||||
case "", defaultOutoutFormat:
|
||||
return img.stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen)
|
||||
return img.stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen, verbose)
|
||||
case "json":
|
||||
return img.stringJSON()
|
||||
case "yml", "yaml":
|
||||
|
@ -1095,7 +1006,7 @@ func (img imageStruct) string(format string, maxImgNameLen, maxTagLen, maxPlatfo
|
|||
}
|
||||
}
|
||||
|
||||
func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen int) (string, error) {
|
||||
func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen int, verbose bool) (string, error) {
|
||||
var builder strings.Builder
|
||||
|
||||
table := getImageTableWriter(&builder)
|
||||
|
@ -1107,7 +1018,7 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen
|
|||
table.SetColMinWidth(colSizeIndex, sizeWidth)
|
||||
table.SetColMinWidth(colIsSignedIndex, isSignedWidth)
|
||||
|
||||
if img.verbose {
|
||||
if verbose {
|
||||
table.SetColMinWidth(colConfigIndex, configWidth)
|
||||
table.SetColMinWidth(colLayersIndex, layersWidth)
|
||||
}
|
||||
|
@ -1138,7 +1049,7 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen
|
|||
tagName += offset
|
||||
}
|
||||
|
||||
err := addImageToTable(table, &img, maxPlatformLen, imageName, tagName)
|
||||
err := addImageToTable(table, &img, maxPlatformLen, imageName, tagName, verbose)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -1149,20 +1060,20 @@ func (img imageStruct) stringPlainText(maxImgNameLen, maxTagLen, maxPlatformLen
|
|||
}
|
||||
|
||||
func addImageToTable(table *tablewriter.Table, img *imageStruct, maxPlatformLen int,
|
||||
imageName, tagName string,
|
||||
imageName, tagName string, verbose bool,
|
||||
) error {
|
||||
switch img.MediaType {
|
||||
case ispec.MediaTypeImageManifest:
|
||||
return addManifestToTable(table, imageName, tagName, &img.Manifests[0], maxPlatformLen, img.verbose)
|
||||
return addManifestToTable(table, imageName, tagName, &img.Manifests[0], maxPlatformLen, verbose)
|
||||
case ispec.MediaTypeImageIndex:
|
||||
return addImageIndexToTable(table, img, maxPlatformLen, imageName, tagName)
|
||||
return addImageIndexToTable(table, img, maxPlatformLen, imageName, tagName, verbose)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func addImageIndexToTable(table *tablewriter.Table, img *imageStruct, maxPlatformLen int,
|
||||
imageName, tagName string,
|
||||
imageName, tagName string, verbose bool,
|
||||
) error {
|
||||
indexDigest, err := godigest.Parse(img.Digest)
|
||||
if err != nil {
|
||||
|
@ -1178,7 +1089,7 @@ func addImageIndexToTable(table *tablewriter.Table, img *imageStruct, maxPlatfor
|
|||
row[colSizeIndex] = ellipsize(strings.ReplaceAll(humanize.Bytes(imgSize), " ", ""), sizeWidth, ellipsis)
|
||||
row[colIsSignedIndex] = strconv.FormatBool(img.IsSigned)
|
||||
|
||||
if img.verbose {
|
||||
if verbose {
|
||||
row[colConfigIndex] = ""
|
||||
row[colLayersIndex] = ""
|
||||
}
|
||||
|
@ -1186,7 +1097,7 @@ func addImageIndexToTable(table *tablewriter.Table, img *imageStruct, maxPlatfor
|
|||
table.Append(row)
|
||||
|
||||
for i := range img.Manifests {
|
||||
err := addManifestToTable(table, "", "", &img.Manifests[i], maxPlatformLen, img.verbose)
|
||||
err := addManifestToTable(table, "", "", &img.Manifests[i], maxPlatformLen, verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1195,7 +1106,7 @@ func addImageIndexToTable(table *tablewriter.Table, img *imageStruct, maxPlatfor
|
|||
return nil
|
||||
}
|
||||
|
||||
func addManifestToTable(table *tablewriter.Table, imageName, tagName string, manifest *manifestStruct,
|
||||
func addManifestToTable(table *tablewriter.Table, imageName, tagName string, manifest *common.ManifestSummary,
|
||||
maxPlatformLen int, verbose bool,
|
||||
) error {
|
||||
manifestDigest, err := godigest.Parse(manifest.Digest)
|
||||
|
@ -1238,8 +1149,8 @@ func addManifestToTable(table *tablewriter.Table, imageName, tagName string, man
|
|||
|
||||
if verbose {
|
||||
for _, entry := range manifest.Layers {
|
||||
layerSize := entry.Size
|
||||
size := ellipsize(strings.ReplaceAll(humanize.Bytes(uint64(layerSize)), " ", ""), sizeWidth, ellipsis)
|
||||
layerSize, _ := strconv.ParseUint(entry.Size, 10, 64)
|
||||
size := ellipsize(strings.ReplaceAll(humanize.Bytes(layerSize), " ", ""), sizeWidth, ellipsis)
|
||||
|
||||
layerDigest, err := godigest.Parse(entry.Digest)
|
||||
if err != nil {
|
||||
|
@ -1264,7 +1175,7 @@ func addManifestToTable(table *tablewriter.Table, imageName, tagName string, man
|
|||
return nil
|
||||
}
|
||||
|
||||
func getPlatformStr(platf platform) string {
|
||||
func getPlatformStr(platf common.Platform) string {
|
||||
if platf.Arch == "" && platf.Os == "" {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -4,6 +4,11 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
type PageInfo struct {
|
||||
TotalCount int
|
||||
ItemCount int
|
||||
}
|
||||
|
||||
type RepoInfo struct {
|
||||
Summary RepoSummary
|
||||
ImageSummaries []ImageSummary `json:"images"`
|
||||
|
@ -21,6 +26,11 @@ type RepoSummary struct {
|
|||
NewestImage ImageSummary `json:"newestImage"`
|
||||
}
|
||||
|
||||
type PaginatedImagesResult struct {
|
||||
Results []ImageSummary `json:"results"`
|
||||
Page PageInfo `json:"page"`
|
||||
}
|
||||
|
||||
type ImageSummary struct {
|
||||
RepoName string `json:"repoName"`
|
||||
Tag string `json:"tag"`
|
||||
|
@ -49,6 +59,7 @@ type ManifestSummary struct {
|
|||
LastUpdated time.Time `json:"lastUpdated"`
|
||||
Size string `json:"size"`
|
||||
Platform Platform `json:"platform"`
|
||||
IsSigned bool `json:"isSigned"`
|
||||
DownloadCount int `json:"downloadCount"`
|
||||
Layers []LayerSummary `json:"layers"`
|
||||
History []LayerHistory `json:"history"`
|
||||
|
@ -58,13 +69,9 @@ type ManifestSummary struct {
|
|||
}
|
||||
|
||||
type Platform struct {
|
||||
Os string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
}
|
||||
|
||||
type ErrorGraphQL struct {
|
||||
Message string `json:"message"`
|
||||
Path []string `json:"path"`
|
||||
Os string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
Variant string `json:"variant"`
|
||||
}
|
||||
|
||||
type ImageVulnerabilitySummary struct {
|
||||
|
@ -103,3 +110,138 @@ type Annotation struct {
|
|||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type FixedTags struct {
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
ImageListWithCVEFixed `json:"data"`
|
||||
}
|
||||
|
||||
type ImageListWithCVEFixed struct {
|
||||
PaginatedImagesResult `json:"ImageListWithCVEFixed"` //nolint:tagliatelle // graphQL schema
|
||||
}
|
||||
|
||||
type ImagesForCve struct {
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
ImagesForCVEList `json:"data"`
|
||||
}
|
||||
|
||||
type ImagesForCVEList struct {
|
||||
PaginatedImagesResult `json:"ImageListForCVE"` //nolint:tagliatelle // graphQL schema
|
||||
}
|
||||
|
||||
type ImagesForDigest struct {
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
ImagesForDigestList `json:"data"`
|
||||
}
|
||||
|
||||
type ImagesForDigestList struct {
|
||||
PaginatedImagesResult `json:"ImageListForDigest"` //nolint:tagliatelle // graphQL schema
|
||||
}
|
||||
|
||||
type RepoWithNewestImageResponse struct {
|
||||
RepoListWithNewestImage `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type DerivedImageListResponse struct {
|
||||
DerivedImageList `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type BaseImageListResponse struct {
|
||||
BaseImageList `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type DerivedImageList struct {
|
||||
PaginatedImagesResult `json:"derivedImageList"`
|
||||
}
|
||||
|
||||
type BaseImageList struct {
|
||||
PaginatedImagesResult `json:"baseImageList"`
|
||||
}
|
||||
|
||||
type ImageListResponse struct {
|
||||
ImageList `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type ImageList struct {
|
||||
PaginatedImagesResult `json:"imageList"`
|
||||
}
|
||||
|
||||
type ExpandedRepoInfoResp struct {
|
||||
ExpandedRepoInfo `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type ReferrersResp struct {
|
||||
ReferrersResult `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type ReferrersResult struct {
|
||||
Referrers []Referrer `json:"referrers"`
|
||||
}
|
||||
type GlobalSearchResultResp struct {
|
||||
GlobalSearchResult `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type GlobalSearchResult struct {
|
||||
GlobalSearch `json:"globalSearch"`
|
||||
}
|
||||
|
||||
type GlobalSearch struct {
|
||||
Images []ImageSummary `json:"images"`
|
||||
Repos []RepoSummary `json:"repos"`
|
||||
Layers []LayerSummary `json:"layers"`
|
||||
Page PageInfo `json:"page"`
|
||||
}
|
||||
|
||||
type ExpandedRepoInfo struct {
|
||||
RepoInfo `json:"expandedRepoInfo"`
|
||||
}
|
||||
|
||||
type PaginatedReposResult struct {
|
||||
Results []RepoSummary `json:"results"`
|
||||
Page PageInfo `json:"page"`
|
||||
}
|
||||
|
||||
//nolint:tagliatelle // graphQL schema
|
||||
type RepoListWithNewestImage struct {
|
||||
PaginatedReposResult `json:"RepoListWithNewestImage"`
|
||||
}
|
||||
|
||||
type ErrorGQL struct {
|
||||
Message string `json:"message"`
|
||||
Path []string `json:"path"`
|
||||
}
|
||||
|
||||
type SingleImageSummary struct {
|
||||
ImageSummary `json:"Image"` //nolint:tagliatelle
|
||||
}
|
||||
type ImageSummaryResult struct {
|
||||
SingleImageSummary `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
//nolint:tagliatelle // graphQL schema
|
||||
type StarredRepos struct {
|
||||
PaginatedReposResult `json:"StarredRepos"`
|
||||
}
|
||||
|
||||
//nolint:tagliatelle // graphQL schema
|
||||
type BookmarkedRepos struct {
|
||||
PaginatedReposResult `json:"BookmarkedRepos"`
|
||||
}
|
||||
|
||||
type StarredReposResponse struct {
|
||||
StarredRepos `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
type BookmarkedReposResponse struct {
|
||||
BookmarkedRepos `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
type CveInfo interface {
|
||||
GetImageListForCVE(repo, cveID string) ([]cvemodel.TagInfo, error)
|
||||
GetImageListWithCVEFixed(repo, cveID string) ([]cvemodel.TagInfo, error)
|
||||
GetCVEListForImage(repo, tag string, searchedCVE string, pageinput PageInput) ([]cvemodel.CVE, PageInfo, error)
|
||||
GetCVEListForImage(repo, tag string, searchedCVE string, pageinput PageInput) ([]cvemodel.CVE, common.PageInfo, error)
|
||||
GetCVESummaryForImage(repo, tag string) (ImageCVESummary, error)
|
||||
CompareSeverities(severity1, severity2 string) int
|
||||
UpdateDB() error
|
||||
|
@ -232,24 +232,24 @@ func filterCVEList(cveMap map[string]cvemodel.CVE, searchedCVE string, pageFinde
|
|||
|
||||
func (cveinfo BaseCveInfo) GetCVEListForImage(repo, tag string, searchedCVE string, pageInput PageInput) (
|
||||
[]cvemodel.CVE,
|
||||
PageInfo,
|
||||
common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
isValidImage, err := cveinfo.Scanner.IsImageFormatScannable(repo, tag)
|
||||
if !isValidImage {
|
||||
return []cvemodel.CVE{}, PageInfo{}, err
|
||||
return []cvemodel.CVE{}, common.PageInfo{}, err
|
||||
}
|
||||
|
||||
image := getImageString(repo, tag)
|
||||
|
||||
cveMap, err := cveinfo.Scanner.ScanImage(image)
|
||||
if err != nil {
|
||||
return []cvemodel.CVE{}, PageInfo{}, err
|
||||
return []cvemodel.CVE{}, common.PageInfo{}, err
|
||||
}
|
||||
|
||||
pageFinder, err := NewCvePageFinder(pageInput.Limit, pageInput.Offset, pageInput.SortBy, cveinfo)
|
||||
if err != nil {
|
||||
return []cvemodel.CVE{}, PageInfo{}, err
|
||||
return []cvemodel.CVE{}, common.PageInfo{}, err
|
||||
}
|
||||
|
||||
filterCVEList(cveMap, searchedCVE, pageFinder)
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"sort"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
)
|
||||
|
||||
|
@ -46,7 +47,7 @@ func SortBySeverity(pageBuffer []cvemodel.CVE, cveInfo CveInfo) func(i, j int) b
|
|||
// and returning a specific page.
|
||||
type PageFinder interface {
|
||||
Add(cve cvemodel.CVE)
|
||||
Page() ([]cvemodel.CVE, PageInfo)
|
||||
Page() ([]cvemodel.CVE, common.PageInfo)
|
||||
Reset()
|
||||
}
|
||||
|
||||
|
@ -94,12 +95,12 @@ func (bpt *CvePageFinder) Add(cve cvemodel.CVE) {
|
|||
bpt.pageBuffer = append(bpt.pageBuffer, cve)
|
||||
}
|
||||
|
||||
func (bpt *CvePageFinder) Page() ([]cvemodel.CVE, PageInfo) {
|
||||
func (bpt *CvePageFinder) Page() ([]cvemodel.CVE, common.PageInfo) {
|
||||
if len(bpt.pageBuffer) == 0 {
|
||||
return []cvemodel.CVE{}, PageInfo{}
|
||||
return []cvemodel.CVE{}, common.PageInfo{}
|
||||
}
|
||||
|
||||
pageInfo := &PageInfo{}
|
||||
pageInfo := &common.PageInfo{}
|
||||
|
||||
sort.Slice(bpt.pageBuffer, SortFunctions()[bpt.sortBy](bpt.pageBuffer, bpt.cveInfo))
|
||||
|
||||
|
@ -131,11 +132,6 @@ func (bpt *CvePageFinder) Page() ([]cvemodel.CVE, PageInfo) {
|
|||
return cves, *pageInfo
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
TotalCount int
|
||||
ItemCount int
|
||||
}
|
||||
|
||||
type PageInput struct {
|
||||
Limit int
|
||||
Offset int
|
||||
|
|
|
@ -18,14 +18,14 @@ import (
|
|||
"zotregistry.io/zot/pkg/api"
|
||||
"zotregistry.io/zot/pkg/api/config"
|
||||
"zotregistry.io/zot/pkg/api/constants"
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
extconf "zotregistry.io/zot/pkg/extensions/config"
|
||||
"zotregistry.io/zot/pkg/meta/repodb"
|
||||
. "zotregistry.io/zot/pkg/test"
|
||||
)
|
||||
|
||||
type ImgResponseForDigest struct {
|
||||
ImgListForDigest ImgListForDigest `json:"data"`
|
||||
Errors []ErrorGQL `json:"errors"`
|
||||
ImgListForDigest ImgListForDigest `json:"data"`
|
||||
Errors []common.ErrorGQL `json:"errors"`
|
||||
}
|
||||
|
||||
//nolint:tagliatelle // graphQL schema
|
||||
|
@ -44,7 +44,7 @@ type ImgInfo struct {
|
|||
|
||||
type PaginatedImagesResultForDigest struct {
|
||||
Results []ImgInfo `json:"results"`
|
||||
Page repodb.PageInfo `json:"page"`
|
||||
Page common.PageInfo `json:"page"`
|
||||
}
|
||||
|
||||
func TestDigestSearchHTTP(t *testing.T) {
|
||||
|
|
|
@ -35,11 +35,11 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchRepos error", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return make([]repodb.RepoMetadata, 0), make(map[string]repodb.ManifestMetadata),
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, ErrTestError
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
}
|
||||
responseContext := graphql.WithResponseContext(context.Background(), graphql.DefaultErrorPresenter,
|
||||
|
@ -56,7 +56,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchRepo is successful", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "repo1",
|
||||
|
@ -115,7 +115,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchRepo Bad manifest referenced", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "repo1",
|
||||
|
@ -175,7 +175,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchRepo good manifest referenced and bad config blob", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "repo1",
|
||||
|
@ -246,7 +246,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -285,11 +285,11 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchTags gives error", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchTagsFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return make([]repodb.RepoMetadata, 0), make(map[string]repodb.ManifestMetadata),
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, ErrTestError
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
}
|
||||
const query = "repo1:1.0.1"
|
||||
|
@ -308,7 +308,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
Convey("RepoDB SearchTags is successful", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchTagsFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "repo1",
|
||||
|
@ -361,7 +361,7 @@ func TestGlobalSearch(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -395,11 +395,11 @@ func TestRepoListWithNewestImage(t *testing.T) {
|
|||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return make([]repodb.RepoMetadata, 0), make(map[string]repodb.ManifestMetadata),
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, ErrTestError
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
}
|
||||
responseContext := graphql.WithResponseContext(context.Background(), graphql.DefaultErrorPresenter,
|
||||
|
@ -422,7 +422,7 @@ func TestRepoListWithNewestImage(t *testing.T) {
|
|||
Convey("RepoDB SearchRepo bad manifest referenced", func() {
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "repo1",
|
||||
|
@ -478,7 +478,7 @@ func TestRepoListWithNewestImage(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -504,7 +504,7 @@ func TestRepoListWithNewestImage(t *testing.T) {
|
|||
createTime2 := createTime.Add(time.Second)
|
||||
mockRepoDB := mocks.RepoDBMock{
|
||||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
pageFinder, err := repodb.NewBaseRepoPageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
|
@ -585,7 +585,7 @@ func TestRepoListWithNewestImage(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
Convey("RepoDB missing requestedPage", func() {
|
||||
|
@ -673,11 +673,11 @@ func TestGetFilteredPaginatedRepos(t *testing.T) {
|
|||
nil,
|
||||
mocks.RepoDBMock{
|
||||
FilterReposFn: func(ctx context.Context, filter repodb.FilterRepoFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
)
|
||||
|
@ -691,11 +691,11 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -709,7 +709,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -736,7 +736,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -757,7 +757,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -790,7 +790,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
|
||||
repos[0].Tags = matchedTags
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -830,7 +830,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -868,7 +868,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
|
||||
repos[0].Tags = matchedTags
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -904,7 +904,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -944,7 +944,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
|
||||
repos[0].Tags = matchedTags
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -978,7 +978,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -1013,7 +1013,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
repos[i].Tags = matchedTags
|
||||
}
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1047,14 +1047,14 @@ func TestImageListForDigest(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset,
|
||||
requestedPage.SortBy)
|
||||
if err != nil {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, err
|
||||
common.PageInfo{}, err
|
||||
}
|
||||
|
||||
repos := []repodb.RepoMetadata{
|
||||
|
@ -1097,7 +1097,7 @@ func TestImageListForDigest(t *testing.T) {
|
|||
|
||||
repos, _ = pageFinder.Page()
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1330,11 +1330,11 @@ func TestImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{},
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, ErrTestError
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1349,7 +1349,7 @@ func TestImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
repos := []repodb.RepoMetadata{
|
||||
{
|
||||
Name: "test",
|
||||
|
@ -1393,7 +1393,7 @@ func TestImageList(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetaDatas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -1558,10 +1558,10 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
mocks.CveInfoMock{},
|
||||
|
@ -1584,10 +1584,10 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
mocks.CveInfoMock{},
|
||||
|
@ -1611,9 +1611,9 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return nil, nil, nil, repodb.PageInfo{}, ErrTestError
|
||||
return nil, nil, nil, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
mocks.CveInfoMock{},
|
||||
|
@ -1635,9 +1635,9 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
SearchReposFn: func(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return nil, nil, nil, repodb.PageInfo{}, ErrTestError
|
||||
return nil, nil, nil, common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
mocks.CveInfoMock{},
|
||||
|
@ -1658,10 +1658,10 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
},
|
||||
mocks.CveInfoMock{},
|
||||
|
@ -1754,10 +1754,10 @@ func TestQueryResolverErrors(t *testing.T) {
|
|||
mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
GetRepoMetaFn: func(repo string) (repodb.RepoMetadata, error) {
|
||||
return repodb.RepoMetadata{
|
||||
|
@ -2588,10 +2588,10 @@ func TestDerivedImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return make([]repodb.RepoMetadata, 0), make(map[string]repodb.ManifestMetadata),
|
||||
make(map[string]repodb.IndexData), repodb.PageInfo{}, ErrTestError
|
||||
make(map[string]repodb.IndexData), common.PageInfo{}, ErrTestError
|
||||
},
|
||||
GetRepoMetaFn: func(repo string) (repodb.RepoMetadata, error) {
|
||||
return repodb.RepoMetadata{}, ErrTestError
|
||||
|
@ -2629,10 +2629,10 @@ func TestDerivedImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, nil
|
||||
common.PageInfo{}, nil
|
||||
},
|
||||
GetRepoMetaFn: func(repo string) (repodb.RepoMetadata, error) {
|
||||
return repodb.RepoMetadata{
|
||||
|
@ -2779,7 +2779,7 @@ func TestDerivedImageList(t *testing.T) {
|
|||
},
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -2857,10 +2857,10 @@ func TestBaseImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, ErrTestError
|
||||
common.PageInfo{}, ErrTestError
|
||||
},
|
||||
GetRepoMetaFn: func(repo string) (repodb.RepoMetadata, error) {
|
||||
return repodb.RepoMetadata{}, ErrTestError
|
||||
|
@ -2898,10 +2898,10 @@ func TestBaseImageList(t *testing.T) {
|
|||
mockSearchDB := mocks.RepoDBMock{
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, nil
|
||||
common.PageInfo{}, nil
|
||||
},
|
||||
GetRepoMetaFn: func(repo string) (repodb.RepoMetadata, error) {
|
||||
return repodb.RepoMetadata{
|
||||
|
@ -3042,7 +3042,7 @@ func TestBaseImageList(t *testing.T) {
|
|||
},
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -3217,7 +3217,7 @@ func TestBaseImageList(t *testing.T) {
|
|||
},
|
||||
FilterTagsFn: func(ctx context.Context, filter repodb.FilterFunc, requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
common.PageInfo, error,
|
||||
) {
|
||||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -3252,7 +3252,7 @@ func TestBaseImageList(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
return repos, manifestMetas, map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
},
|
||||
}
|
||||
responseContext := graphql.WithResponseContext(context.Background(), graphql.DefaultErrorPresenter,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -147,7 +147,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := StarredReposResponse{}
|
||||
responseStruct := common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -162,7 +162,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 1)
|
||||
|
@ -181,7 +181,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -196,7 +196,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := StarredReposResponse{}
|
||||
responseStruct := common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -211,7 +211,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -226,7 +226,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := StarredReposResponse{}
|
||||
responseStruct := common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -241,7 +241,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -256,7 +256,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := StarredReposResponse{}
|
||||
responseStruct := common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -271,7 +271,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 1)
|
||||
|
@ -290,7 +290,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = StarredReposResponse{}
|
||||
responseStruct = common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -305,7 +305,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := BookmarkedReposResponse{}
|
||||
responseStruct := common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -320,7 +320,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 1)
|
||||
|
@ -338,7 +338,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -353,7 +353,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := BookmarkedReposResponse{}
|
||||
responseStruct := common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -368,7 +368,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -383,7 +383,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := BookmarkedReposResponse{}
|
||||
responseStruct := common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -398,7 +398,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -413,7 +413,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := BookmarkedReposResponse{}
|
||||
responseStruct := common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -428,7 +428,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 1)
|
||||
|
@ -446,7 +446,7 @@ func TestUserData(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = BookmarkedReposResponse{}
|
||||
responseStruct = common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 0)
|
||||
|
@ -577,7 +577,7 @@ func TestChangingRepoState(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||
|
||||
responseStruct := StarredReposResponse{}
|
||||
responseStruct := common.StarredReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(len(responseStruct.Results), ShouldEqual, 1)
|
||||
|
@ -599,7 +599,7 @@ func TestChangingRepoState(t *testing.T) {
|
|||
So(resp, ShouldNotBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, http.StatusOK)
|
||||
|
||||
responseStruct := BookmarkedReposResponse{}
|
||||
responseStruct := common.BookmarkedReposResponse{}
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
So(err, ShouldBeNil)
|
||||
|
@ -714,12 +714,12 @@ func TestGlobalSearchWithUserPrefFiltering(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := &GlobalSearchResultResp{}
|
||||
responseStruct := &common.GlobalSearchResultResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
foundRepos := responseStruct.GlobalSearchResult.GlobalSearch.Repos
|
||||
foundRepos := responseStruct.Repos
|
||||
So(len(foundRepos), ShouldEqual, 4)
|
||||
|
||||
// Filter by IsStarred = true
|
||||
|
@ -730,12 +730,12 @@ func TestGlobalSearchWithUserPrefFiltering(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = &GlobalSearchResultResp{}
|
||||
responseStruct = &common.GlobalSearchResultResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
foundRepos = responseStruct.GlobalSearchResult.GlobalSearch.Repos
|
||||
foundRepos = responseStruct.Repos
|
||||
So(len(foundRepos), ShouldEqual, 2)
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: sRepo, IsStarred: true, IsBookmarked: false})
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: sbRepo, IsStarred: true, IsBookmarked: true})
|
||||
|
@ -752,12 +752,12 @@ func TestGlobalSearchWithUserPrefFiltering(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = &GlobalSearchResultResp{}
|
||||
responseStruct = &common.GlobalSearchResultResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
foundRepos = responseStruct.GlobalSearchResult.GlobalSearch.Repos
|
||||
foundRepos = responseStruct.Repos
|
||||
So(len(foundRepos), ShouldEqual, 1)
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: sRepo, IsStarred: true, IsBookmarked: false})
|
||||
|
||||
|
@ -773,12 +773,12 @@ func TestGlobalSearchWithUserPrefFiltering(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = &GlobalSearchResultResp{}
|
||||
responseStruct = &common.GlobalSearchResultResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
foundRepos = responseStruct.GlobalSearchResult.GlobalSearch.Repos
|
||||
foundRepos = responseStruct.Repos
|
||||
So(len(foundRepos), ShouldEqual, 2)
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: bRepo, IsStarred: false, IsBookmarked: true})
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: sbRepo, IsStarred: true, IsBookmarked: true})
|
||||
|
@ -795,12 +795,12 @@ func TestGlobalSearchWithUserPrefFiltering(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = &GlobalSearchResultResp{}
|
||||
responseStruct = &common.GlobalSearchResultResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
foundRepos = responseStruct.GlobalSearchResult.GlobalSearch.Repos
|
||||
foundRepos = responseStruct.Repos
|
||||
So(len(foundRepos), ShouldEqual, 1)
|
||||
So(foundRepos, ShouldContain, common.RepoSummary{Name: bRepo, IsStarred: false, IsBookmarked: true})
|
||||
})
|
||||
|
@ -886,12 +886,12 @@ func TestExpandedRepoInfoWithUserPrefs(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct := ExpandedRepoInfoResp{}
|
||||
responseStruct := common.ExpandedRepoInfoResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
repoInfo := responseStruct.ExpandedRepoInfo.RepoInfo
|
||||
repoInfo := responseStruct.RepoInfo
|
||||
So(repoInfo.Summary.IsBookmarked, ShouldBeTrue)
|
||||
So(repoInfo.Summary.IsStarred, ShouldBeTrue)
|
||||
|
||||
|
@ -921,12 +921,12 @@ func TestExpandedRepoInfoWithUserPrefs(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = ExpandedRepoInfoResp{}
|
||||
responseStruct = common.ExpandedRepoInfoResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
repoInfo = responseStruct.ExpandedRepoInfo.RepoInfo
|
||||
repoInfo = responseStruct.RepoInfo
|
||||
So(repoInfo.Summary.IsBookmarked, ShouldBeFalse)
|
||||
So(repoInfo.Summary.IsStarred, ShouldBeTrue)
|
||||
|
||||
|
@ -956,12 +956,12 @@ func TestExpandedRepoInfoWithUserPrefs(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = ExpandedRepoInfoResp{}
|
||||
responseStruct = common.ExpandedRepoInfoResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
repoInfo = responseStruct.ExpandedRepoInfo.RepoInfo
|
||||
repoInfo = responseStruct.RepoInfo
|
||||
So(repoInfo.Summary.IsBookmarked, ShouldBeTrue)
|
||||
So(repoInfo.Summary.IsStarred, ShouldBeFalse)
|
||||
|
||||
|
@ -987,12 +987,12 @@ func TestExpandedRepoInfoWithUserPrefs(t *testing.T) {
|
|||
So(err, ShouldBeNil)
|
||||
So(resp.StatusCode(), ShouldEqual, 200)
|
||||
|
||||
responseStruct = ExpandedRepoInfoResp{}
|
||||
responseStruct = common.ExpandedRepoInfoResp{}
|
||||
|
||||
err = json.Unmarshal(resp.Body(), &responseStruct)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
repoInfo = responseStruct.ExpandedRepoInfo.RepoInfo
|
||||
repoInfo = responseStruct.RepoInfo
|
||||
So(repoInfo.Summary.IsBookmarked, ShouldBeFalse)
|
||||
So(repoInfo.Summary.IsStarred, ShouldBeFalse)
|
||||
})
|
||||
|
|
|
@ -961,7 +961,7 @@ func (bdw *DBWrapper) DeleteSignature(repo string, signedManifestDigest godigest
|
|||
|
||||
func (bdw *DBWrapper) SearchRepos(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo,
|
||||
error,
|
||||
) {
|
||||
var (
|
||||
|
@ -969,13 +969,13 @@ func (bdw *DBWrapper) SearchRepos(ctx context.Context, searchText string, filter
|
|||
foundManifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
foundindexDataMap = make(map[string]repodb.IndexData)
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
)
|
||||
|
||||
pageFinder, err := repodb.NewBaseRepoPageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
if err != nil {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, err
|
||||
zcommon.PageInfo{}, err
|
||||
}
|
||||
|
||||
err = bdw.DB.View(func(transaction *bbolt.Tx) error {
|
||||
|
@ -1291,7 +1291,7 @@ func NewManifestMetadata(manifestDigest string, repoMeta repodb.RepoMetadata,
|
|||
func (bdw *DBWrapper) FilterTags(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData,
|
||||
repodb.PageInfo, error,
|
||||
zcommon.PageInfo, error,
|
||||
) {
|
||||
var (
|
||||
foundRepos = make([]repodb.RepoMetadata, 0)
|
||||
|
@ -1300,13 +1300,13 @@ func (bdw *DBWrapper) FilterTags(ctx context.Context, filter repodb.FilterFunc,
|
|||
foundManifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
foundindexDataMap = make(map[string]repodb.IndexData)
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
)
|
||||
|
||||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
if err != nil {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, err
|
||||
zcommon.PageInfo{}, err
|
||||
}
|
||||
|
||||
err = bdw.DB.View(func(transaction *bbolt.Tx) error {
|
||||
|
@ -1432,12 +1432,12 @@ func (bdw *DBWrapper) FilterRepos(ctx context.Context,
|
|||
filter repodb.FilterRepoFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error,
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error,
|
||||
) {
|
||||
var (
|
||||
foundRepos = make([]repodb.RepoMetadata, 0)
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
)
|
||||
|
||||
pageFinder, err := repodb.NewBaseRepoPageFinder(
|
||||
|
@ -1494,14 +1494,14 @@ func (bdw *DBWrapper) FilterRepos(ctx context.Context,
|
|||
|
||||
func (bdw *DBWrapper) SearchTags(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error) {
|
||||
var (
|
||||
foundRepos = make([]repodb.RepoMetadata, 0)
|
||||
manifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
indexDataMap = make(map[string]repodb.IndexData)
|
||||
foundManifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
foundindexDataMap = make(map[string]repodb.IndexData)
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
|
||||
pageFinder repodb.PageFinder
|
||||
)
|
||||
|
@ -1509,13 +1509,13 @@ func (bdw *DBWrapper) SearchTags(ctx context.Context, searchText string, filter
|
|||
pageFinder, err := repodb.NewBaseImagePageFinder(requestedPage.Limit, requestedPage.Offset, requestedPage.SortBy)
|
||||
if err != nil {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{}, err
|
||||
zcommon.PageInfo{}, err
|
||||
}
|
||||
|
||||
searchedRepo, searchedTag, err := common.GetRepoTag(searchText)
|
||||
if err != nil {
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{}, map[string]repodb.IndexData{},
|
||||
repodb.PageInfo{},
|
||||
zcommon.PageInfo{},
|
||||
fmt.Errorf("repodb: error while parsing search text, invalid format %w", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -769,13 +769,13 @@ func (dwr *DBWrapper) GetMultipleRepoMeta(ctx context.Context,
|
|||
|
||||
func (dwr *DBWrapper) SearchRepos(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error) {
|
||||
var (
|
||||
manifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
indexDataMap = make(map[string]repodb.IndexData)
|
||||
repoMetaAttributeIterator dynamo.AttributesIterator
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
|
||||
userBookmarks = getUserBookmarks(ctx, dwr)
|
||||
userStars = getUserStars(ctx, dwr)
|
||||
|
@ -1077,13 +1077,13 @@ func (dwr *DBWrapper) collectImageIndexFilterInfo(indexDigest string, repoMeta r
|
|||
|
||||
func (dwr *DBWrapper) FilterTags(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error) {
|
||||
var (
|
||||
manifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
indexDataMap = make(map[string]repodb.IndexData)
|
||||
repoMetaAttributeIterator dynamo.AttributesIterator
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
userBookmarks = getUserBookmarks(ctx, dwr)
|
||||
userStars = getUserStars(ctx, dwr)
|
||||
)
|
||||
|
@ -1224,11 +1224,11 @@ func (dwr *DBWrapper) FilterRepos(ctx context.Context,
|
|||
filter repodb.FilterRepoFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error,
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error,
|
||||
) {
|
||||
var (
|
||||
repoMetaAttributeIterator dynamo.AttributesIterator
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
userBookmarks = getUserBookmarks(ctx, dwr)
|
||||
userStars = getUserStars(ctx, dwr)
|
||||
)
|
||||
|
@ -1282,13 +1282,13 @@ func (dwr *DBWrapper) FilterRepos(ctx context.Context,
|
|||
|
||||
func (dwr *DBWrapper) SearchTags(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, zcommon.PageInfo, error) {
|
||||
var (
|
||||
manifestMetadataMap = make(map[string]repodb.ManifestMetadata)
|
||||
indexDataMap = make(map[string]repodb.IndexData)
|
||||
repoMetaAttributeIterator dynamo.AttributesIterator
|
||||
pageFinder repodb.PageFinder
|
||||
pageInfo repodb.PageInfo
|
||||
pageInfo zcommon.PageInfo
|
||||
userBookmarks = getUserBookmarks(ctx, dwr)
|
||||
userStars = getUserStars(ctx, dwr)
|
||||
)
|
||||
|
|
|
@ -5,13 +5,14 @@ import (
|
|||
"sort"
|
||||
|
||||
zerr "zotregistry.io/zot/errors"
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
)
|
||||
|
||||
// PageFinder permits keeping a pool of objects using Add
|
||||
// and returning a specific page.
|
||||
type PageFinder interface {
|
||||
Add(detailedRepoMeta DetailedRepoMeta)
|
||||
Page() ([]RepoMetadata, PageInfo)
|
||||
Page() ([]RepoMetadata, common.PageInfo)
|
||||
Reset()
|
||||
}
|
||||
|
||||
|
@ -58,12 +59,12 @@ func (bpt *RepoPageFinder) Add(namedRepoMeta DetailedRepoMeta) {
|
|||
bpt.pageBuffer = append(bpt.pageBuffer, namedRepoMeta)
|
||||
}
|
||||
|
||||
func (bpt *RepoPageFinder) Page() ([]RepoMetadata, PageInfo) {
|
||||
func (bpt *RepoPageFinder) Page() ([]RepoMetadata, common.PageInfo) {
|
||||
if len(bpt.pageBuffer) == 0 {
|
||||
return []RepoMetadata{}, PageInfo{}
|
||||
return []RepoMetadata{}, common.PageInfo{}
|
||||
}
|
||||
|
||||
pageInfo := &PageInfo{}
|
||||
pageInfo := &common.PageInfo{}
|
||||
|
||||
sort.Slice(bpt.pageBuffer, SortFunctions()[bpt.sortBy](bpt.pageBuffer))
|
||||
|
||||
|
@ -142,12 +143,12 @@ func (bpt *ImagePageFinder) Add(namedRepoMeta DetailedRepoMeta) {
|
|||
bpt.pageBuffer = append(bpt.pageBuffer, namedRepoMeta)
|
||||
}
|
||||
|
||||
func (bpt *ImagePageFinder) Page() ([]RepoMetadata, PageInfo) {
|
||||
func (bpt *ImagePageFinder) Page() ([]RepoMetadata, common.PageInfo) {
|
||||
if len(bpt.pageBuffer) == 0 {
|
||||
return []RepoMetadata{}, PageInfo{}
|
||||
return []RepoMetadata{}, common.PageInfo{}
|
||||
}
|
||||
|
||||
pageInfo := PageInfo{}
|
||||
pageInfo := common.PageInfo{}
|
||||
|
||||
for _, drm := range bpt.pageBuffer {
|
||||
repo := drm.RepoMetadata
|
||||
|
@ -190,7 +191,7 @@ func (bpt *ImagePageFinder) Page() ([]RepoMetadata, PageInfo) {
|
|||
|
||||
// offset is larger than the number of tags
|
||||
if repoStartIndex >= len(bpt.pageBuffer) {
|
||||
return []RepoMetadata{}, PageInfo{}
|
||||
return []RepoMetadata{}, common.PageInfo{}
|
||||
}
|
||||
|
||||
// finish counting remaining tags inside the first repo meta
|
||||
|
|
|
@ -5,6 +5,8 @@ import (
|
|||
"time"
|
||||
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
)
|
||||
|
||||
// Used to model changes to an object after a call to the DB.
|
||||
|
@ -95,19 +97,19 @@ type RepoDB interface { //nolint:interfacebloat
|
|||
|
||||
// SearchRepos searches for repos given a search string
|
||||
SearchRepos(ctx context.Context, searchText string, filter Filter, requestedPage PageInput) (
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, PageInfo, error)
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, common.PageInfo, error)
|
||||
|
||||
// SearchTags searches for images(repo:tag) given a search string
|
||||
SearchTags(ctx context.Context, searchText string, filter Filter, requestedPage PageInput) (
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, PageInfo, error)
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, common.PageInfo, error)
|
||||
|
||||
// FilterRepos filters for repos given a filter function
|
||||
FilterRepos(ctx context.Context, filter FilterRepoFunc, requestedPage PageInput) (
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, PageInfo, error)
|
||||
[]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, common.PageInfo, error)
|
||||
|
||||
// FilterTags filters for images given a filter function
|
||||
FilterTags(ctx context.Context, filter FilterFunc,
|
||||
requestedPage PageInput) ([]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, PageInfo, error)
|
||||
requestedPage PageInput) ([]RepoMetadata, map[string]ManifestMetadata, map[string]IndexData, common.PageInfo, error)
|
||||
|
||||
// GetStarredRepos returns starred repos and takes current user in consideration
|
||||
GetStarredRepos(ctx context.Context) ([]string, error)
|
||||
|
@ -216,11 +218,6 @@ type PageInput struct {
|
|||
SortBy SortCriteria
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
TotalCount int
|
||||
ItemCount int
|
||||
}
|
||||
|
||||
type Filter struct {
|
||||
Os []*string
|
||||
Arch []*string
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mocks
|
||||
|
||||
import (
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
cveinfo "zotregistry.io/zot/pkg/extensions/search/cve"
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
)
|
||||
|
@ -9,7 +10,7 @@ type CveInfoMock struct {
|
|||
GetImageListForCVEFn func(repo, cveID string) ([]cvemodel.TagInfo, error)
|
||||
GetImageListWithCVEFixedFn func(repo, cveID string) ([]cvemodel.TagInfo, error)
|
||||
GetCVEListForImageFn func(repo string, reference string, searchedCVE string, pageInput cveinfo.PageInput,
|
||||
) ([]cvemodel.CVE, cveinfo.PageInfo, error)
|
||||
) ([]cvemodel.CVE, common.PageInfo, error)
|
||||
GetCVESummaryForImageFn func(repo string, reference string,
|
||||
) (cveinfo.ImageCVESummary, error)
|
||||
CompareSeveritiesFn func(severity1, severity2 string) int
|
||||
|
@ -36,14 +37,14 @@ func (cveInfo CveInfoMock) GetCVEListForImage(repo string, reference string,
|
|||
searchedCVE string, pageInput cveinfo.PageInput,
|
||||
) (
|
||||
[]cvemodel.CVE,
|
||||
cveinfo.PageInfo,
|
||||
common.PageInfo,
|
||||
error,
|
||||
) {
|
||||
if cveInfo.GetCVEListForImageFn != nil {
|
||||
return cveInfo.GetCVEListForImageFn(repo, reference, searchedCVE, pageInput)
|
||||
}
|
||||
|
||||
return []cvemodel.CVE{}, cveinfo.PageInfo{}, nil
|
||||
return []cvemodel.CVE{}, common.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetCVESummaryForImage(repo string, reference string,
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
"zotregistry.io/zot/pkg/meta/repodb"
|
||||
)
|
||||
|
||||
|
@ -62,17 +63,17 @@ type RepoDBMock struct {
|
|||
DeleteSignatureFn func(repo string, signedManifestDigest godigest.Digest, sm repodb.SignatureMetadata) error
|
||||
|
||||
SearchReposFn func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error)
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error)
|
||||
|
||||
SearchTagsFn func(ctx context.Context, searchText string, filter repodb.Filter, requestedPage repodb.PageInput) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error)
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error)
|
||||
|
||||
FilterReposFn func(ctx context.Context, filter repodb.FilterRepoFunc, requestedPage repodb.PageInput) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error)
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error)
|
||||
|
||||
FilterTagsFn func(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error)
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error)
|
||||
|
||||
SearchDigestsFn func(ctx context.Context, searchText string, requestedPage repodb.PageInput) (
|
||||
[]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, error)
|
||||
|
@ -251,46 +252,46 @@ func (sdm RepoDBMock) DeleteSignature(repo string, signedManifestDigest godigest
|
|||
|
||||
func (sdm RepoDBMock) SearchRepos(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
if sdm.SearchReposFn != nil {
|
||||
return sdm.SearchReposFn(ctx, searchText, filter, requestedPage)
|
||||
}
|
||||
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{},
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (sdm RepoDBMock) SearchTags(ctx context.Context, searchText string, filter repodb.Filter,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
if sdm.SearchTagsFn != nil {
|
||||
return sdm.SearchTagsFn(ctx, searchText, filter, requestedPage)
|
||||
}
|
||||
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{},
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (sdm RepoDBMock) FilterRepos(ctx context.Context, filter repodb.FilterRepoFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
if sdm.FilterReposFn != nil {
|
||||
return sdm.FilterReposFn(ctx, filter, requestedPage)
|
||||
}
|
||||
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{},
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (sdm RepoDBMock) FilterTags(ctx context.Context, filter repodb.FilterFunc,
|
||||
requestedPage repodb.PageInput,
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, repodb.PageInfo, error) {
|
||||
) ([]repodb.RepoMetadata, map[string]repodb.ManifestMetadata, map[string]repodb.IndexData, common.PageInfo, error) {
|
||||
if sdm.FilterTagsFn != nil {
|
||||
return sdm.FilterTagsFn(ctx, filter, requestedPage)
|
||||
}
|
||||
|
||||
return []repodb.RepoMetadata{}, map[string]repodb.ManifestMetadata{},
|
||||
map[string]repodb.IndexData{}, repodb.PageInfo{}, nil
|
||||
map[string]repodb.IndexData{}, common.PageInfo{}, nil
|
||||
}
|
||||
|
||||
func (sdm RepoDBMock) SearchDigests(ctx context.Context, searchText string, requestedPage repodb.PageInput,
|
||||
|
|
Loading…
Reference in a new issue