( ctx context.Context, art pkg.RegistryInfo, man manifest.Manifest, contentType string, )
| 486 | } |
| 487 | |
| 488 | func (m *ManifestListCache) push( |
| 489 | ctx context.Context, art pkg.RegistryInfo, man manifest.Manifest, contentType string, |
| 490 | ) error { |
| 491 | if len(man.References()) == 0 { |
| 492 | return errors.New("manifest list doesn't contain any pushed manifest") |
| 493 | } |
| 494 | _, pl, err := man.Payload() |
| 495 | if err != nil { |
| 496 | log.Ctx(ctx).Error().Msgf("failed to get payload, error %v", err) |
| 497 | return err |
| 498 | } |
| 499 | log.Ctx(ctx).Debug().Msgf("The manifest list payload: %v", string(pl)) |
| 500 | newDig := digest.FromBytes(pl) |
| 501 | // Because the manifest list maybe updated, need to recheck if it is exist in local |
| 502 | _, descriptor, manifest2, _ := m.localRegistry.PullManifest(ctx, art, nil, nil) |
| 503 | if manifest2 != nil && descriptor.Digest == newDig { |
| 504 | return nil |
| 505 | } |
| 506 | |
| 507 | _, errs := m.localRegistry.PutManifest(ctx, art, contentType, ByteToReadCloser(pl), int64(len(pl))) |
| 508 | if len(errs) > 0 { |
| 509 | return errs[0] |
| 510 | } |
| 511 | return nil |
| 512 | } |
no test coverage detected