Skip to content

Commit 738a236

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 <jakob.moeller@sap.com>
1 parent dcf6d55 commit 738a236

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 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"
@@ -10,9 +11,9 @@ import (
1011
"github.com/mandelsoft/goutils/errors"
1112
"github.com/mandelsoft/goutils/finalizer"
1213
"github.com/opencontainers/go-digest"
13-
1414
"ocm.software/ocm/api/oci"
1515
"ocm.software/ocm/api/oci/artdesc"
16+
"ocm.software/ocm/api/oci/extensions/repositories/artifactset"
1617
"ocm.software/ocm/api/ocm/cpi/accspeccpi"
1718
"ocm.software/ocm/api/ocm/extensions/accessmethods/localblob"
1819
"ocm.software/ocm/api/utils/blobaccess/blobaccess"
@@ -99,8 +100,15 @@ func (m *localBlobAccessMethod) getBlob() (blobaccess.DataAccess, error) {
99100
err error
100101
)
101102
if len(refs) < 2 {
102-
_, data, err = m.namespace.GetBlobData(digest.Digest(m.spec.LocalReference))
103-
if err != nil {
103+
if m.spec.MediaType == artdesc.MediaTypeImageIndex || m.spec.MediaType == artdesc.MediaTypeImageManifest {
104+
// if we have a nested manifest or index, we can use the blob synthesis utility here to download
105+
// the entire artifact set.
106+
artblob, err := artifactset.SynthesizeArtifactBlob(m.namespace, m.spec.LocalReference)
107+
if err != nil {
108+
return nil, fmt.Errorf("failed to synthesize artifact blob: %w", err)
109+
}
110+
data = artblob
111+
} else if _, data, err = m.namespace.GetBlobData(digest.Digest(m.spec.LocalReference)); err != nil {
104112
return nil, err
105113
}
106114
} else {
@@ -126,7 +134,7 @@ func (m *localBlobAccessMethod) MimeType() string {
126134
return m.spec.MediaType
127135
}
128136

129-
////////////////////////////////////////////////////////////////////////////////
137+
// //////////////////////////////////////////////////////////////////////////////
130138

131139
type composedBlock struct {
132140
m *localBlobAccessMethod

0 commit comments

Comments
 (0)