2023-01-09 15:37:44 -05:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
godigest "github.com/opencontainers/go-digest"
|
|
|
|
|
2023-05-25 13:27:49 -05:00
|
|
|
"zotregistry.io/zot/pkg/common"
|
2023-07-18 12:27:26 -05:00
|
|
|
mTypes "zotregistry.io/zot/pkg/meta/types"
|
2023-01-09 15:37:44 -05:00
|
|
|
)
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
type MetaDBMock struct {
|
2023-01-09 15:37:44 -05:00
|
|
|
SetRepoDescriptionFn func(repo, description string) error
|
|
|
|
|
|
|
|
IncrementRepoStarsFn func(repo string) error
|
|
|
|
|
|
|
|
DecrementRepoStarsFn func(repo string) error
|
|
|
|
|
|
|
|
GetRepoStarsFn func(repo string) (int, error)
|
|
|
|
|
|
|
|
SetRepoLogoFn func(repo string, logoPath string) error
|
|
|
|
|
2023-03-09 13:41:48 -05:00
|
|
|
SetRepoReferenceFn func(repo string, Reference string, manifestDigest godigest.Digest, mediaType string) error
|
2023-01-09 15:37:44 -05:00
|
|
|
|
|
|
|
DeleteRepoTagFn func(repo string, tag string) error
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetRepoMetaFn func(repo string) (mTypes.RepoMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetUserRepoMetaFn func(ctx context.Context, repo string) (mTypes.RepoMetadata, error)
|
2023-05-04 11:51:21 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetRepoMetaFn func(repo string, repoMeta mTypes.RepoMetadata) error
|
2023-03-23 13:08:11 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetMultipleRepoMetaFn func(ctx context.Context, filter func(repoMeta mTypes.RepoMetadata) bool,
|
|
|
|
requestedPage mTypes.PageInput) ([]mTypes.RepoMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetManifestDataFn func(manifestDigest godigest.Digest) (mTypes.ManifestData, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetManifestDataFn func(manifestDigest godigest.Digest, mm mTypes.ManifestData) error
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetManifestMetaFn func(repo string, manifestDigest godigest.Digest) (mTypes.ManifestMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetManifestMetaFn func(repo string, manifestDigest godigest.Digest, mm mTypes.ManifestMetadata) error
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetIndexDataFn func(digest godigest.Digest, indexData mTypes.IndexData) error
|
2023-02-27 14:23:18 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetIndexDataFn func(indexDigest godigest.Digest) (mTypes.IndexData, error)
|
2023-02-27 14:23:18 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetReferrerFn func(repo string, referredDigest godigest.Digest, referrer mTypes.ReferrerInfo) error
|
2023-03-10 13:37:29 -05:00
|
|
|
|
|
|
|
DeleteReferrerFn func(repo string, referredDigest godigest.Digest, referrerDigest godigest.Digest) error
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetReferrersFn func(repo string, referredDigest godigest.Digest) ([]mTypes.Descriptor, error)
|
2023-03-10 13:37:29 -05:00
|
|
|
|
2023-03-20 11:14:17 -05:00
|
|
|
GetReferrersInfoFn func(repo string, referredDigest godigest.Digest, artifactTypes []string) (
|
2023-07-18 12:27:26 -05:00
|
|
|
[]mTypes.ReferrerInfo, error)
|
2023-03-10 13:37:29 -05:00
|
|
|
|
2023-01-09 15:37:44 -05:00
|
|
|
IncrementImageDownloadsFn func(repo string, reference string) error
|
|
|
|
|
2023-05-24 11:46:16 -05:00
|
|
|
UpdateSignaturesValidityFn func(repo string, manifestDigest godigest.Digest) error
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
AddManifestSignatureFn func(repo string, signedManifestDigest godigest.Digest, sm mTypes.SignatureMetadata) error
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
DeleteSignatureFn func(repo string, signedManifestDigest godigest.Digest, sm mTypes.SignatureMetadata) error
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchReposFn func(ctx context.Context, txt string, filter mTypes.Filter, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo,
|
|
|
|
error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchTagsFn func(ctx context.Context, txt string, filter mTypes.Filter, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo,
|
|
|
|
error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
FilterReposFn func(ctx context.Context, filter mTypes.FilterRepoFunc, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo,
|
|
|
|
error)
|
2023-04-24 13:13:15 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
FilterTagsFn func(ctx context.Context, filterFunc mTypes.FilterFunc, filter mTypes.Filter,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo,
|
|
|
|
error)
|
2023-01-17 17:31:54 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchDigestsFn func(ctx context.Context, searchText string, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchLayersFn func(ctx context.Context, searchText string, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchForAscendantImagesFn func(ctx context.Context, searchText string, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SearchForDescendantImagesFn func(ctx context.Context, searchText string, requestedPage mTypes.PageInput) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-04-24 13:13:15 -05:00
|
|
|
GetStarredReposFn func(ctx context.Context) ([]string, error)
|
|
|
|
|
|
|
|
GetBookmarkedReposFn func(ctx context.Context) ([]string, error)
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
ToggleStarRepoFn func(ctx context.Context, repo string) (mTypes.ToggleState, error)
|
2023-04-24 13:13:15 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
ToggleBookmarkRepoFn func(ctx context.Context, repo string) (mTypes.ToggleState, error)
|
2023-04-24 13:13:15 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
GetUserDataFn func(ctx context.Context) (mTypes.UserData, error)
|
2023-07-07 11:27:10 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
SetUserDataFn func(ctx context.Context, userProfile mTypes.UserData) error
|
2023-07-07 11:27:10 -05:00
|
|
|
|
|
|
|
SetUserGroupsFn func(ctx context.Context, groups []string) error
|
|
|
|
|
|
|
|
GetUserGroupsFn func(ctx context.Context) ([]string, error)
|
|
|
|
|
|
|
|
DeleteUserDataFn func(ctx context.Context) error
|
|
|
|
|
|
|
|
GetUserAPIKeyInfoFn func(hashedKey string) (string, error)
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
AddUserAPIKeyFn func(ctx context.Context, hashedKey string, apiKeyDetails *mTypes.APIKeyDetails) error
|
2023-07-07 11:27:10 -05:00
|
|
|
|
|
|
|
UpdateUserAPIKeyLastUsedFn func(ctx context.Context, hashedKey string) error
|
|
|
|
|
|
|
|
DeleteUserAPIKeyFn func(ctx context.Context, id string) error
|
|
|
|
|
2023-01-09 15:37:44 -05:00
|
|
|
PatchDBFn func() error
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetRepoDescription(repo, description string) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SetRepoDescriptionFn != nil {
|
|
|
|
return sdm.SetRepoDescriptionFn(repo, description)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) IncrementRepoStars(repo string) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.IncrementRepoStarsFn != nil {
|
|
|
|
return sdm.IncrementRepoStarsFn(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DecrementRepoStars(repo string) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.DecrementRepoStarsFn != nil {
|
|
|
|
return sdm.DecrementRepoStarsFn(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetRepoStars(repo string) (int, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetRepoStarsFn != nil {
|
|
|
|
return sdm.GetRepoStarsFn(repo)
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0, nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetRepoReference(repo string, reference string, manifestDigest godigest.Digest,
|
2023-03-09 13:41:48 -05:00
|
|
|
mediaType string,
|
|
|
|
) error {
|
|
|
|
if sdm.SetRepoReferenceFn != nil {
|
|
|
|
return sdm.SetRepoReferenceFn(repo, reference, manifestDigest, mediaType)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DeleteRepoTag(repo string, tag string) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.DeleteRepoTagFn != nil {
|
|
|
|
return sdm.DeleteRepoTagFn(repo, tag)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetRepoMeta(repo string) (mTypes.RepoMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetRepoMetaFn != nil {
|
|
|
|
return sdm.GetRepoMetaFn(repo)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.RepoMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetUserRepoMeta(ctx context.Context, repo string) (mTypes.RepoMetadata, error) {
|
2023-05-04 11:51:21 -05:00
|
|
|
if sdm.GetUserRepoMetaFn != nil {
|
|
|
|
return sdm.GetUserRepoMetaFn(ctx, repo)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.RepoMetadata{}, nil
|
2023-05-04 11:51:21 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetRepoMeta(repo string, repoMeta mTypes.RepoMetadata) error {
|
2023-03-23 13:08:11 -05:00
|
|
|
if sdm.SetRepoMetaFn != nil {
|
|
|
|
return sdm.SetRepoMetaFn(repo, repoMeta)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetMultipleRepoMeta(ctx context.Context, filter func(repoMeta mTypes.RepoMetadata) bool,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetMultipleRepoMetaFn != nil {
|
|
|
|
return sdm.GetMultipleRepoMetaFn(ctx, filter, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetManifestData(manifestDigest godigest.Digest) (mTypes.ManifestData, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetManifestDataFn != nil {
|
2023-02-27 14:23:18 -05:00
|
|
|
return sdm.GetManifestDataFn(manifestDigest)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.ManifestData{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetManifestData(manifestDigest godigest.Digest, md mTypes.ManifestData) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SetManifestDataFn != nil {
|
2023-02-27 14:23:18 -05:00
|
|
|
return sdm.SetManifestDataFn(manifestDigest, md)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetManifestMeta(repo string, manifestDigest godigest.Digest) (mTypes.ManifestMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetManifestMetaFn != nil {
|
|
|
|
return sdm.GetManifestMetaFn(repo, manifestDigest)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.ManifestMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetManifestMeta(repo string, manifestDigest godigest.Digest, mm mTypes.ManifestMetadata) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SetManifestMetaFn != nil {
|
|
|
|
return sdm.SetManifestMetaFn(repo, manifestDigest, mm)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) IncrementImageDownloads(repo string, reference string) error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.IncrementImageDownloadsFn != nil {
|
|
|
|
return sdm.IncrementImageDownloadsFn(repo, reference)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) UpdateSignaturesValidity(repo string, manifestDigest godigest.Digest) error {
|
2023-05-24 11:46:16 -05:00
|
|
|
if sdm.UpdateSignaturesValidityFn != nil {
|
|
|
|
return sdm.UpdateSignaturesValidityFn(repo, manifestDigest)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) AddManifestSignature(repo string, signedManifestDigest godigest.Digest,
|
|
|
|
sm mTypes.SignatureMetadata,
|
2023-01-09 15:37:44 -05:00
|
|
|
) error {
|
|
|
|
if sdm.AddManifestSignatureFn != nil {
|
|
|
|
return sdm.AddManifestSignatureFn(repo, signedManifestDigest, sm)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DeleteSignature(repo string, signedManifestDigest godigest.Digest,
|
|
|
|
sm mTypes.SignatureMetadata,
|
2023-01-09 15:37:44 -05:00
|
|
|
) error {
|
|
|
|
if sdm.DeleteSignatureFn != nil {
|
|
|
|
return sdm.DeleteSignatureFn(repo, signedManifestDigest, sm)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchRepos(ctx context.Context, searchText string, filter mTypes.Filter,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchReposFn != nil {
|
|
|
|
return sdm.SearchReposFn(ctx, searchText, filter, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
|
|
|
map[string]mTypes.IndexData{}, common.PageInfo{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchTags(ctx context.Context, searchText string, filter mTypes.Filter,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchTagsFn != nil {
|
|
|
|
return sdm.SearchTagsFn(ctx, searchText, filter, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
|
|
|
map[string]mTypes.IndexData{}, common.PageInfo{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) FilterRepos(ctx context.Context, filter mTypes.FilterRepoFunc,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.FilterReposFn != nil {
|
|
|
|
return sdm.FilterReposFn(ctx, filter, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
|
|
|
map[string]mTypes.IndexData{}, common.PageInfo{}, nil
|
2023-04-24 13:13:15 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) FilterTags(ctx context.Context, filterFunc mTypes.FilterFunc, filter mTypes.Filter,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, common.PageInfo, error) {
|
2023-01-17 17:31:54 -05:00
|
|
|
if sdm.FilterTagsFn != nil {
|
2023-07-11 11:29:04 -05:00
|
|
|
return sdm.FilterTagsFn(ctx, filterFunc, filter, requestedPage)
|
2023-01-17 17:31:54 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
|
|
|
map[string]mTypes.IndexData{}, common.PageInfo{}, nil
|
2023-01-17 17:31:54 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchDigests(ctx context.Context, searchText string, requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchDigestsFn != nil {
|
|
|
|
return sdm.SearchDigestsFn(ctx, searchText, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchLayers(ctx context.Context, searchText string, requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchLayersFn != nil {
|
|
|
|
return sdm.SearchLayersFn(ctx, searchText, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchForAscendantImages(ctx context.Context, searchText string,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchForAscendantImagesFn != nil {
|
|
|
|
return sdm.SearchForAscendantImagesFn(ctx, searchText, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SearchForDescendantImages(ctx context.Context, searchText string,
|
|
|
|
requestedPage mTypes.PageInput,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchForDescendantImagesFn != nil {
|
|
|
|
return sdm.SearchForDescendantImagesFn(ctx, searchText, requestedPage)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetIndexData(digest godigest.Digest, indexData mTypes.IndexData) error {
|
2023-02-27 14:23:18 -05:00
|
|
|
if sdm.SetIndexDataFn != nil {
|
|
|
|
return sdm.SetIndexDataFn(digest, indexData)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetIndexData(indexDigest godigest.Digest) (mTypes.IndexData, error) {
|
2023-02-27 14:23:18 -05:00
|
|
|
if sdm.GetIndexDataFn != nil {
|
|
|
|
return sdm.GetIndexDataFn(indexDigest)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.IndexData{}, nil
|
2023-02-27 14:23:18 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) PatchDB() error {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.PatchDBFn != nil {
|
|
|
|
return sdm.PatchDBFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2023-03-10 13:37:29 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetReferrer(repo string, referredDigest godigest.Digest, referrer mTypes.ReferrerInfo) error {
|
2023-03-10 13:37:29 -05:00
|
|
|
if sdm.SetReferrerFn != nil {
|
|
|
|
return sdm.SetReferrerFn(repo, referredDigest, referrer)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DeleteReferrer(repo string, referredDigest godigest.Digest,
|
2023-03-10 13:37:29 -05:00
|
|
|
referrerDigest godigest.Digest,
|
|
|
|
) error {
|
|
|
|
if sdm.DeleteReferrerFn != nil {
|
|
|
|
return sdm.DeleteReferrerFn(repo, referredDigest, referrerDigest)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetReferrersInfo(repo string, referredDigest godigest.Digest,
|
2023-03-10 13:37:29 -05:00
|
|
|
artifactTypes []string,
|
2023-07-18 12:27:26 -05:00
|
|
|
) ([]mTypes.ReferrerInfo, error) {
|
2023-03-20 11:14:17 -05:00
|
|
|
if sdm.GetReferrersInfoFn != nil {
|
|
|
|
return sdm.GetReferrersInfoFn(repo, referredDigest, artifactTypes)
|
2023-03-10 13:37:29 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.ReferrerInfo{}, nil
|
2023-03-10 13:37:29 -05:00
|
|
|
}
|
2023-04-24 13:13:15 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetStarredRepos(ctx context.Context) ([]string, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.GetStarredReposFn != nil {
|
|
|
|
return sdm.GetStarredReposFn(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return []string{}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetBookmarkedRepos(ctx context.Context) ([]string, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.GetBookmarkedReposFn != nil {
|
|
|
|
return sdm.GetBookmarkedReposFn(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return []string{}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) ToggleStarRepo(ctx context.Context, repo string) (mTypes.ToggleState, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.ToggleStarRepoFn != nil {
|
|
|
|
return sdm.ToggleStarRepoFn(ctx, repo)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.NotChanged, nil
|
2023-04-24 13:13:15 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) ToggleBookmarkRepo(ctx context.Context, repo string) (mTypes.ToggleState, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.ToggleBookmarkRepoFn != nil {
|
|
|
|
return sdm.ToggleBookmarkRepoFn(ctx, repo)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.NotChanged, nil
|
2023-04-24 13:13:15 -05:00
|
|
|
}
|
2023-07-07 11:27:10 -05:00
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetUserData(ctx context.Context) (mTypes.UserData, error) {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.GetUserDataFn != nil {
|
|
|
|
return sdm.GetUserDataFn(ctx)
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return mTypes.UserData{}, nil
|
2023-07-07 11:27:10 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetUserData(ctx context.Context, userProfile mTypes.UserData) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.SetUserDataFn != nil {
|
|
|
|
return sdm.SetUserDataFn(ctx, userProfile)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) SetUserGroups(ctx context.Context, groups []string) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.SetUserGroupsFn != nil {
|
|
|
|
return sdm.SetUserGroupsFn(ctx, groups)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetUserGroups(ctx context.Context) ([]string, error) {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.GetUserGroupsFn != nil {
|
|
|
|
return sdm.GetUserGroupsFn(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return []string{}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DeleteUserData(ctx context.Context) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.DeleteUserDataFn != nil {
|
|
|
|
return sdm.DeleteUserDataFn(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) GetUserAPIKeyInfo(hashedKey string) (string, error) {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.GetUserAPIKeyInfoFn != nil {
|
|
|
|
return sdm.GetUserAPIKeyInfoFn(hashedKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) AddUserAPIKey(ctx context.Context, hashedKey string, apiKeyDetails *mTypes.APIKeyDetails) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.AddUserAPIKeyFn != nil {
|
|
|
|
return sdm.AddUserAPIKeyFn(ctx, hashedKey, apiKeyDetails)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) UpdateUserAPIKeyLastUsed(ctx context.Context, hashedKey string) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.UpdateUserAPIKeyLastUsedFn != nil {
|
|
|
|
return sdm.UpdateUserAPIKeyLastUsedFn(ctx, hashedKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
func (sdm MetaDBMock) DeleteUserAPIKey(ctx context.Context, id string) error {
|
2023-07-07 11:27:10 -05:00
|
|
|
if sdm.DeleteUserAPIKeyFn != nil {
|
|
|
|
return sdm.DeleteUserAPIKeyFn(ctx, id)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|