(ctx context.Context, t *testing.T, client *Client, dstFile *os.File, mfst ocispec.Descriptor)
| 287 | } |
| 288 | |
| 289 | func isImageInArchive(ctx context.Context, t *testing.T, client *Client, dstFile *os.File, mfst ocispec.Descriptor) bool { |
| 290 | dstFile.Seek(0, 0) |
| 291 | tr := tar.NewReader(dstFile) |
| 292 | |
| 293 | var blobs []string |
| 294 | for { |
| 295 | h, err := tr.Next() |
| 296 | if err != nil { |
| 297 | if err == io.EOF { |
| 298 | break |
| 299 | } |
| 300 | t.Fatal(err) |
| 301 | } |
| 302 | |
| 303 | digest := strings.TrimPrefix(h.Name, "blobs/sha256/") |
| 304 | if digest != h.Name && digest != "" { |
| 305 | blobs = append(blobs, digest) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | allPresent := true |
| 310 | // Check if the archive contains all blobs referenced by the manifest. |
| 311 | images.Walk(ctx, images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { |
| 312 | if slices.Contains(blobs, desc.Digest.Hex()) { |
| 313 | return images.Children(ctx, client.ContentStore(), desc) |
| 314 | } |
| 315 | allPresent = false |
| 316 | return nil, images.ErrStopHandler |
| 317 | }), mfst) |
| 318 | |
| 319 | return allPresent |
| 320 | } |
| 321 | |
| 322 | func getPlatformManifest(ctx context.Context, cs content.Store, target ocispec.Descriptor, platform platforms.MatchComparer) (ocispec.Descriptor, error) { |
| 323 | mfst, err := images.LimitManifests(images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { |
no test coverage detected
searching dependent graphs…