mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +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
+25
-6
@@ -212,8 +212,10 @@ func GetRandomImageConfig() ([]byte, godigest.Digest) {
|
||||
randomAuthor := randomString(maxLen)
|
||||
|
||||
config := imagespec.Image{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
Platform: imagespec.Platform{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
},
|
||||
RootFS: imagespec.RootFS{
|
||||
Type: "layers",
|
||||
DiffIDs: []godigest.Digest{},
|
||||
@@ -231,10 +233,25 @@ func GetRandomImageConfig() ([]byte, godigest.Digest) {
|
||||
return configBlobContent, configBlobDigestRaw
|
||||
}
|
||||
|
||||
func GetEmptyImageConfig() ([]byte, godigest.Digest) {
|
||||
config := imagespec.Image{}
|
||||
|
||||
configBlobContent, err := json.MarshalIndent(&config, "", "\t")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
configBlobDigestRaw := godigest.FromBytes(configBlobContent)
|
||||
|
||||
return configBlobContent, configBlobDigestRaw
|
||||
}
|
||||
|
||||
func GetImageConfig() ([]byte, godigest.Digest) {
|
||||
config := imagespec.Image{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
Platform: imagespec.Platform{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
},
|
||||
RootFS: imagespec.RootFS{
|
||||
Type: "layers",
|
||||
DiffIDs: []godigest.Digest{},
|
||||
@@ -305,8 +322,10 @@ func GetOciLayoutDigests(imagePath string) (godigest.Digest, godigest.Digest, go
|
||||
|
||||
func GetImageComponents(layerSize int) (imagespec.Image, [][]byte, imagespec.Manifest, error) {
|
||||
config := imagespec.Image{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
Platform: imagespec.Platform{
|
||||
Architecture: "amd64",
|
||||
OS: "linux",
|
||||
},
|
||||
RootFS: imagespec.RootFS{
|
||||
Type: "layers",
|
||||
DiffIDs: []godigest.Digest{},
|
||||
|
||||
@@ -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