MountBlob into the registry, so it can be referenced by a manifest
(ctx context.Context, sourceRef reference.Canonical, targetRef reference.Named)
| 66 | |
| 67 | // MountBlob into the registry, so it can be referenced by a manifest |
| 68 | func (c *client) MountBlob(ctx context.Context, sourceRef reference.Canonical, targetRef reference.Named) error { |
| 69 | repoEndpoint, err := newDefaultRepositoryEndpoint(targetRef, c.insecureRegistry) |
| 70 | if err != nil { |
| 71 | return err |
| 72 | } |
| 73 | repoEndpoint.actions = []string{"pull", "push"} |
| 74 | repo, err := c.getRepositoryForReference(ctx, targetRef, repoEndpoint) |
| 75 | if err != nil { |
| 76 | return err |
| 77 | } |
| 78 | lu, err := repo.Blobs(ctx).Create(ctx, distributionclient.WithMountFrom(sourceRef)) |
| 79 | switch err.(type) { |
| 80 | case distribution.ErrBlobMounted: |
| 81 | logrus.Debugf("mount of blob %s succeeded", sourceRef) |
| 82 | return nil |
| 83 | case nil: |
| 84 | default: |
| 85 | return fmt.Errorf("failed to mount blob %s to %s: %w", sourceRef, targetRef, err) |
| 86 | } |
| 87 | _ = lu.Cancel(ctx) |
| 88 | logrus.Debugf("mount of blob %s created", sourceRef) |
| 89 | return ErrBlobCreated{From: sourceRef, Target: targetRef} |
| 90 | } |
| 91 | |
| 92 | // PutManifest sends the manifest to a registry and returns the new digest |
| 93 | func (c *client) PutManifest(ctx context.Context, ref reference.Named, manifest distribution.Manifest) (digest.Digest, error) { |
nothing calls this directly
no test coverage detected