MCPcopy
hub / github.com/harness/harness / push

Method push

registry/app/remote/controller/proxy/controller.go:488–512  ·  view source on GitHub ↗
(
	ctx context.Context, art pkg.RegistryInfo, man manifest.Manifest, contentType string,
)

Source from the content-addressed store, hash-verified

486}
487
488func (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}

Callers 1

CacheContentMethod · 0.95

Calls 9

NewFunction · 0.92
ByteToReadCloserFunction · 0.85
MsgfMethod · 0.80
ReferencesMethod · 0.65
PayloadMethod · 0.65
ErrorMethod · 0.65
DebugMethod · 0.65
PullManifestMethod · 0.65
PutManifestMethod · 0.65

Tested by

no test coverage detected