2023-01-09 15:37:44 -05:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
godigest "github.com/opencontainers/go-digest"
|
|
|
|
|
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
|
|
|
|
2023-09-22 13:51:20 -05:00
|
|
|
RemoveRepoReferenceFn func(repo, reference string, manifestDigest godigest.Digest) 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-31 14:16:09 -05:00
|
|
|
GetMultipleRepoMetaFn func(ctx context.Context, filter func(repoMeta mTypes.RepoMetadata) bool) (
|
|
|
|
[]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-31 14:16:09 -05:00
|
|
|
SearchReposFn func(ctx context.Context, txt string) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData,
|
2023-07-18 12:27:26 -05:00
|
|
|
error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-31 14:16:09 -05:00
|
|
|
SearchTagsFn func(ctx context.Context, txt string) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData,
|
2023-07-18 12:27:26 -05:00
|
|
|
error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-31 14:16:09 -05:00
|
|
|
FilterReposFn func(ctx context.Context, filter mTypes.FilterRepoFunc) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, error)
|
2023-01-09 15:37:44 -05:00
|
|
|
|
2023-07-31 14:16:09 -05:00
|
|
|
FilterTagsFn func(ctx context.Context, filterFunc mTypes.FilterFunc) (
|
|
|
|
[]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, 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-08-29 11:38:38 -05:00
|
|
|
IsAPIKeyExpiredFn func(ctx context.Context, hashedKey string) (bool, error)
|
|
|
|
|
|
|
|
GetUserAPIKeysFn func(ctx context.Context) ([]mTypes.APIKeyDetails, 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-09-08 02:03:58 -05:00
|
|
|
|
|
|
|
ImageTrustStoreFn func() mTypes.ImageTrustStore
|
|
|
|
|
|
|
|
SetImageTrustStoreFn func(mTypes.ImageTrustStore)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sdm MetaDBMock) ImageTrustStore() mTypes.ImageTrustStore {
|
|
|
|
if sdm.ImageTrustStoreFn != nil {
|
|
|
|
return sdm.ImageTrustStoreFn()
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sdm MetaDBMock) SetImageTrustStore(imgTrustStore mTypes.ImageTrustStore) {
|
|
|
|
if sdm.SetImageTrustStoreFn != nil {
|
|
|
|
sdm.SetImageTrustStoreFn(imgTrustStore)
|
|
|
|
}
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
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-09-22 13:51:20 -05:00
|
|
|
func (sdm MetaDBMock) RemoveRepoReference(repo, reference string, manifestDigest godigest.Digest) error {
|
|
|
|
if sdm.RemoveRepoReferenceFn != nil {
|
|
|
|
return sdm.RemoveRepoReferenceFn(repo, reference, manifestDigest)
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
) ([]mTypes.RepoMetadata, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.GetMultipleRepoMetaFn != nil {
|
2023-07-31 14:16:09 -05:00
|
|
|
return sdm.GetMultipleRepoMetaFn(ctx, filter)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
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-31 14:16:09 -05:00
|
|
|
func (sdm MetaDBMock) SearchRepos(ctx context.Context, searchText string,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchReposFn != nil {
|
2023-07-31 14:16:09 -05:00
|
|
|
return sdm.SearchReposFn(ctx, searchText)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
2023-07-31 14:16:09 -05:00
|
|
|
map[string]mTypes.IndexData{}, nil
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-31 14:16:09 -05:00
|
|
|
func (sdm MetaDBMock) SearchTags(ctx context.Context, searchText string,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, error) {
|
2023-01-09 15:37:44 -05:00
|
|
|
if sdm.SearchTagsFn != nil {
|
2023-07-31 14:16:09 -05:00
|
|
|
return sdm.SearchTagsFn(ctx, searchText)
|
2023-01-09 15:37:44 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
2023-07-31 14:16:09 -05:00
|
|
|
map[string]mTypes.IndexData{}, 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,
|
2023-07-31 14:16:09 -05:00
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, error) {
|
2023-04-24 13:13:15 -05:00
|
|
|
if sdm.FilterReposFn != nil {
|
2023-07-31 14:16:09 -05:00
|
|
|
return sdm.FilterReposFn(ctx, filter)
|
2023-04-24 13:13:15 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
2023-07-31 14:16:09 -05:00
|
|
|
map[string]mTypes.IndexData{}, nil
|
2023-04-24 13:13:15 -05:00
|
|
|
}
|
|
|
|
|
2023-07-31 14:16:09 -05:00
|
|
|
func (sdm MetaDBMock) FilterTags(ctx context.Context, filterFunc mTypes.FilterFunc,
|
|
|
|
) ([]mTypes.RepoMetadata, map[string]mTypes.ManifestMetadata, map[string]mTypes.IndexData, error) {
|
2023-01-17 17:31:54 -05:00
|
|
|
if sdm.FilterTagsFn != nil {
|
2023-07-31 14:16:09 -05:00
|
|
|
return sdm.FilterTagsFn(ctx, filterFunc)
|
2023-01-17 17:31:54 -05:00
|
|
|
}
|
|
|
|
|
2023-07-18 12:27:26 -05:00
|
|
|
return []mTypes.RepoMetadata{}, map[string]mTypes.ManifestMetadata{},
|
2023-07-31 14:16:09 -05:00
|
|
|
map[string]mTypes.IndexData{}, 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-08-29 11:38:38 -05:00
|
|
|
func (sdm MetaDBMock) IsAPIKeyExpired(ctx context.Context, hashedKey string) (bool, error) {
|
|
|
|
if sdm.IsAPIKeyExpiredFn != nil {
|
|
|
|
return sdm.IsAPIKeyExpiredFn(ctx, hashedKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sdm MetaDBMock) GetUserAPIKeys(ctx context.Context) ([]mTypes.APIKeyDetails, error) {
|
|
|
|
if sdm.GetUserAPIKeysFn != nil {
|
|
|
|
return sdm.GetUserAPIKeysFn(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, 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
|
|
|
|
}
|