return index on get magifest
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
package operator
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"mstore/pkg/auxoci"
|
||||
"mstore/pkg/auxtool"
|
||||
"mstore/pkg/auxuuid"
|
||||
"mstore/pkg/descr"
|
||||
@@ -18,6 +21,42 @@ import (
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
func indexFromManigestDescrs(manifestDescrs []descr.Manifest) (ocispec.Index, string, error) {
|
||||
var err error
|
||||
var payload string
|
||||
index := ocispec.Index{
|
||||
MediaType: ocispec.MediaTypeImageIndex,
|
||||
Manifests: make([]ocispec.Descriptor, 0),
|
||||
}
|
||||
index.Versioned.SchemaVersion = 2
|
||||
for _, manifestDescr := range manifestDescrs {
|
||||
var ociManifest ocispec.Manifest
|
||||
|
||||
ociManifest.Subject = &ocispec.Descriptor{}
|
||||
ociManifest.Subject.Platform = &ocispec.Platform{}
|
||||
ociManifest.Config = ocispec.Descriptor{}
|
||||
ociManifest.Config.Platform = &ocispec.Platform{}
|
||||
|
||||
err = json.Unmarshal([]byte(manifestDescr.Payload), &ociManifest)
|
||||
if err != nil {
|
||||
return index, payload, err
|
||||
}
|
||||
descriptor := ocispec.Descriptor{
|
||||
MediaType: ocispec.MediaTypeImageManifest,
|
||||
Digest: auxoci.SHA256DigestFromString(manifestDescr.Payload),
|
||||
Size: int64(len(manifestDescr.Payload)),
|
||||
Platform: ociManifest.Subject.Platform,
|
||||
}
|
||||
index.Manifests = append(index.Manifests, descriptor)
|
||||
}
|
||||
indexBytes, err := json.Marshal(index)
|
||||
if err != nil {
|
||||
return index, payload, err
|
||||
}
|
||||
payload = string(indexBytes)
|
||||
return index, payload, err
|
||||
}
|
||||
|
||||
func descrsFromManifest(name, reference string, manifest *ocispec.Manifest, rawManifest []byte) (descr.Manifest, []descr.Blob, error) {
|
||||
var err error
|
||||
manifestDescr := descr.Manifest{}
|
||||
|
||||
Reference in New Issue
Block a user