Skip to content

Commit 7ce6b75

Browse files
fix: handle nested artifact manifests in local blob access method
Added support to synthesize artifact blobs for nested OCI image manifests or indexes in cases where fewer references are provided. Updated error handling and blob synthesis logic accordingly. Signed-off-by: Jakob Möller <[email protected]> Signed-off-by: Jakob Möller <[email protected]>
1 parent 1c184d2 commit 7ce6b75

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

api/ocm/extensions/repositories/genericocireg/accessmethod_localblob.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package genericocireg
22

33
import (
44
"bytes"
5+
"fmt"
56
"io"
67
"os"
78
"strings"
@@ -13,6 +14,7 @@ import (
1314

1415
"ocm.software/ocm/api/oci"
1516
"ocm.software/ocm/api/oci/artdesc"
17+
"ocm.software/ocm/api/oci/extensions/repositories/artifactset"
1618
"ocm.software/ocm/api/ocm/cpi/accspeccpi"
1719
"ocm.software/ocm/api/ocm/extensions/accessmethods/localblob"
1820
"ocm.software/ocm/api/utils/blobaccess/blobaccess"
@@ -99,8 +101,15 @@ func (m *localBlobAccessMethod) getBlob() (blobaccess.DataAccess, error) {
99101
err error
100102
)
101103
if len(refs) < 2 {
102-
_, data, err = m.namespace.GetBlobData(digest.Digest(m.spec.LocalReference))
103-
if err != nil {
104+
if m.spec.MediaType == artdesc.MediaTypeImageIndex || m.spec.MediaType == artdesc.MediaTypeImageManifest {
105+
// if we have a nested manifest or index, we can use the blob synthesis utility here to download
106+
// the entire artifact set.
107+
artblob, err := artifactset.SynthesizeArtifactBlob(m.namespace, m.spec.LocalReference)
108+
if err != nil {
109+
return nil, fmt.Errorf("failed to synthesize artifact blob: %w", err)
110+
}
111+
data = artblob
112+
} else if _, data, err = m.namespace.GetBlobData(digest.Digest(m.spec.LocalReference)); err != nil {
104113
return nil, err
105114
}
106115
} else {
@@ -126,7 +135,7 @@ func (m *localBlobAccessMethod) MimeType() string {
126135
return m.spec.MediaType
127136
}
128137

129-
////////////////////////////////////////////////////////////////////////////////
138+
// //////////////////////////////////////////////////////////////////////////////
130139

131140
type composedBlock struct {
132141
m *localBlobAccessMethod

api/ocm/extensions/repositories/genericocireg/componentversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/mandelsoft/goutils/set"
1111
"github.com/mandelsoft/vfs/pkg/vfs"
1212
"github.com/opencontainers/go-digest"
13+
1314
"ocm.software/ocm/api/datacontext/attrs/vfsattr"
1415
"ocm.software/ocm/api/oci"
1516
"ocm.software/ocm/api/oci/artdesc"

0 commit comments

Comments
 (0)