@@ -299,13 +299,13 @@ func (as ArtifactStore) getArtifacts(ctx context.Context, _ *libartTypes.GetArti
299
299
if err != nil {
300
300
return nil , err
301
301
}
302
- manifests , err := getManifests (ctx , imgSrc , nil )
302
+ manifest , err := getManifest (ctx , imgSrc )
303
303
imgSrc .Close ()
304
304
if err != nil {
305
305
return nil , err
306
306
}
307
307
artifact := libartifact.Artifact {
308
- Manifests : manifests ,
308
+ Manifest : manifest ,
309
309
}
310
310
if val , ok := l .ManifestDescriptor .Annotations [specV1 .AnnotationRefName ]; ok {
311
311
artifact .SetName (val )
@@ -316,41 +316,25 @@ func (as ArtifactStore) getArtifacts(ctx context.Context, _ *libartTypes.GetArti
316
316
return al , nil
317
317
}
318
318
319
- // getManifests takes an imgSrc and starting digest (nil means "top") and collects all the manifests "under"
320
- // it. this func calls itself recursively with a new startingDigest assuming that we are dealing with
321
- // an index list
322
- func getManifests (ctx context.Context , imgSrc types.ImageSource , startingDigest * digest.Digest ) ([]manifest.OCI1 , error ) {
323
- var (
324
- manifests []manifest.OCI1
325
- )
326
- b , manifestType , err := imgSrc .GetManifest (ctx , startingDigest )
319
+ // getManifest takes an imgSrc and returns the manifest for the imgSrc.
320
+ // A OCI index list is not supported and will return an error.
321
+ func getManifest (ctx context.Context , imgSrc types.ImageSource ) (* manifest.OCI1 , error ) {
322
+ b , manifestType , err := imgSrc .GetManifest (ctx , nil )
327
323
if err != nil {
328
324
return nil , err
329
325
}
330
326
331
- // this assumes that there are only single, and multi-images
332
- if ! manifest .MIMETypeIsMultiImage (manifestType ) {
333
- // these are the keepers
334
- mani , err := manifest .OCI1FromManifest (b )
335
- if err != nil {
336
- return nil , err
337
- }
338
- manifests = append (manifests , * mani )
339
- return manifests , nil
327
+ // We only support a single flat manifest and not an oci index list
328
+ if manifest .MIMETypeIsMultiImage (manifestType ) {
329
+ return nil , fmt .Errorf ("manifest %q is index list" , imgSrc .Reference ().StringWithinTransport ())
340
330
}
341
- // We are dealing with an oci index list
342
- maniList , err := manifest .OCI1IndexFromManifest (b )
331
+
332
+ // parse the single manifest
333
+ mani , err := manifest .OCI1FromManifest (b )
343
334
if err != nil {
344
335
return nil , err
345
336
}
346
- for _ , m := range maniList .Manifests {
347
- iterManifests , err := getManifests (ctx , imgSrc , & m .Digest )
348
- if err != nil {
349
- return nil , err
350
- }
351
- manifests = append (manifests , iterManifests ... )
352
- }
353
- return manifests , nil
337
+ return mani , nil
354
338
}
355
339
356
340
func createEmptyStanza (path string ) error {
0 commit comments