mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 20:38:08 +08:00
feat(artifact): add OCI references support (#936)
Thanks @jdolitsky et al for kicking off these changes at: https://github.com/oci-playground/zot/commits/main Thanks @sudo-bmitch for reviewing the patch Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
committed by
GitHub
parent
eb722905cb
commit
c0f93caacb
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
godigest "github.com/opencontainers/go-digest"
|
||||
ispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
|
||||
|
||||
"zotregistry.io/zot/pkg/scheduler"
|
||||
@@ -39,7 +40,8 @@ type MockedImageStore struct {
|
||||
DeleteBlobFn func(repo string, digest godigest.Digest) error
|
||||
GetIndexContentFn func(repo string) ([]byte, error)
|
||||
GetBlobContentFn func(repo string, digest godigest.Digest) ([]byte, error)
|
||||
GetReferrersFn func(repo string, digest godigest.Digest, mediaType string) ([]artifactspec.Descriptor, error)
|
||||
GetReferrersFn func(repo string, digest godigest.Digest, artifactType string) (ispec.Index, error)
|
||||
GetOrasReferrersFn func(repo string, digest godigest.Digest, artifactType string) ([]artifactspec.Descriptor, error)
|
||||
URLForPathFn func(path string) (string, error)
|
||||
RunGCRepoFn func(repo string) error
|
||||
RunGCPeriodicallyFn func(interval time.Duration, sch *scheduler.Scheduler)
|
||||
@@ -287,12 +289,23 @@ func (is MockedImageStore) GetBlobContent(repo string, digest godigest.Digest) (
|
||||
}
|
||||
|
||||
func (is MockedImageStore) GetReferrers(
|
||||
repo string, digest godigest.Digest,
|
||||
artifactType string,
|
||||
) (ispec.Index, error) {
|
||||
if is.GetReferrersFn != nil {
|
||||
return is.GetReferrersFn(repo, digest, artifactType)
|
||||
}
|
||||
|
||||
return ispec.Index{}, nil
|
||||
}
|
||||
|
||||
func (is MockedImageStore) GetOrasReferrers(
|
||||
repo string,
|
||||
digest godigest.Digest,
|
||||
mediaType string,
|
||||
artifactType string,
|
||||
) ([]artifactspec.Descriptor, error) {
|
||||
if is.GetReferrersFn != nil {
|
||||
return is.GetReferrersFn(repo, digest, mediaType)
|
||||
if is.GetOrasReferrersFn != nil {
|
||||
return is.GetOrasReferrersFn(repo, digest, artifactType)
|
||||
}
|
||||
|
||||
return []artifactspec.Descriptor{}, nil
|
||||
|
||||
Reference in New Issue
Block a user