mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
refactor: remove pkg/extensions/search/common and move the code to the appropriate packages (#1358)
Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"zotregistry.io/zot/pkg/extensions/search/common"
|
||||
cveinfo "zotregistry.io/zot/pkg/extensions/search/cve"
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
)
|
||||
|
||||
type CveInfoMock struct {
|
||||
GetImageListForCVEFn func(repo, cveID string) ([]common.TagInfo, error)
|
||||
GetImageListWithCVEFixedFn func(repo, cveID string) ([]common.TagInfo, error)
|
||||
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)
|
||||
GetCVESummaryForImageFn func(repo string, reference string,
|
||||
@@ -17,20 +16,20 @@ type CveInfoMock struct {
|
||||
UpdateDBFn func() error
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetImageListForCVE(repo, cveID string) ([]common.TagInfo, error) {
|
||||
func (cveInfo CveInfoMock) GetImageListForCVE(repo, cveID string) ([]cvemodel.TagInfo, error) {
|
||||
if cveInfo.GetImageListForCVEFn != nil {
|
||||
return cveInfo.GetImageListForCVEFn(repo, cveID)
|
||||
}
|
||||
|
||||
return []common.TagInfo{}, nil
|
||||
return []cvemodel.TagInfo{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetImageListWithCVEFixed(repo, cveID string) ([]common.TagInfo, error) {
|
||||
func (cveInfo CveInfoMock) GetImageListWithCVEFixed(repo, cveID string) ([]cvemodel.TagInfo, error) {
|
||||
if cveInfo.GetImageListWithCVEFixedFn != nil {
|
||||
return cveInfo.GetImageListWithCVEFixedFn(repo, cveID)
|
||||
}
|
||||
|
||||
return []common.TagInfo{}, nil
|
||||
return []cvemodel.TagInfo{}, nil
|
||||
}
|
||||
|
||||
func (cveInfo CveInfoMock) GetCVEListForImage(repo string, reference string,
|
||||
|
||||
@@ -4,7 +4,8 @@ import (
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
"zotregistry.io/zot/pkg/extensions/search/common"
|
||||
"zotregistry.io/zot/pkg/common"
|
||||
cvemodel "zotregistry.io/zot/pkg/extensions/search/cve/model"
|
||||
)
|
||||
|
||||
type OciLayoutUtilsMock struct {
|
||||
@@ -12,11 +13,11 @@ type OciLayoutUtilsMock struct {
|
||||
GetImageManifestsFn func(repo string) ([]ispec.Descriptor, error)
|
||||
GetImageBlobManifestFn func(repo string, digest godigest.Digest) (ispec.Manifest, error)
|
||||
GetImageInfoFn func(repo string, digest godigest.Digest) (ispec.Image, error)
|
||||
GetImageTagsWithTimestampFn func(repo string) ([]common.TagInfo, error)
|
||||
GetImageTagsWithTimestampFn func(repo string) ([]cvemodel.TagInfo, error)
|
||||
GetImagePlatformFn func(imageInfo ispec.Image) (string, string)
|
||||
GetImageManifestSizeFn func(repo string, manifestDigest godigest.Digest) int64
|
||||
GetImageConfigSizeFn func(repo string, manifestDigest godigest.Digest) int64
|
||||
GetRepoLastUpdatedFn func(repo string) (common.TagInfo, error)
|
||||
GetRepoLastUpdatedFn func(repo string) (cvemodel.TagInfo, error)
|
||||
GetExpandedRepoInfoFn func(name string) (common.RepoInfo, error)
|
||||
GetImageConfigInfoFn func(repo string, manifestDigest godigest.Digest) (ispec.Image, error)
|
||||
CheckManifestSignatureFn func(name string, digest godigest.Digest) bool
|
||||
@@ -64,12 +65,12 @@ func (olum OciLayoutUtilsMock) GetImageInfo(repo string, digest godigest.Digest)
|
||||
return ispec.Image{}, nil
|
||||
}
|
||||
|
||||
func (olum OciLayoutUtilsMock) GetImageTagsWithTimestamp(repo string) ([]common.TagInfo, error) {
|
||||
func (olum OciLayoutUtilsMock) GetImageTagsWithTimestamp(repo string) ([]cvemodel.TagInfo, error) {
|
||||
if olum.GetImageTagsWithTimestampFn != nil {
|
||||
return olum.GetImageTagsWithTimestampFn(repo)
|
||||
}
|
||||
|
||||
return []common.TagInfo{}, nil
|
||||
return []cvemodel.TagInfo{}, nil
|
||||
}
|
||||
|
||||
func (olum OciLayoutUtilsMock) GetImagePlatform(imageInfo ispec.Image) (string, string) {
|
||||
@@ -96,12 +97,12 @@ func (olum OciLayoutUtilsMock) GetImageConfigSize(repo string, manifestDigest go
|
||||
return 0
|
||||
}
|
||||
|
||||
func (olum OciLayoutUtilsMock) GetRepoLastUpdated(repo string) (common.TagInfo, error) {
|
||||
func (olum OciLayoutUtilsMock) GetRepoLastUpdated(repo string) (cvemodel.TagInfo, error) {
|
||||
if olum.GetRepoLastUpdatedFn != nil {
|
||||
return olum.GetRepoLastUpdatedFn(repo)
|
||||
}
|
||||
|
||||
return common.TagInfo{}, nil
|
||||
return cvemodel.TagInfo{}, nil
|
||||
}
|
||||
|
||||
func (olum OciLayoutUtilsMock) GetExpandedRepoInfo(name string) (common.RepoInfo, error) {
|
||||
|
||||
Reference in New Issue
Block a user