Skip to content

Commit

Permalink
nydusify: fix unnecessary manifest index when copy one platform image
Browse files Browse the repository at this point in the history
When use the command to copy the image with specified one platform:

```
nydusify copy --platform linux/amd64 --source nginx --target localhost:5000/nginx
```

We found the target image is a manifest index format like:

```
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
  "manifests": [
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "digest": "sha256:d2e65182b5fd330470eca9b8e23e8a1a0d87cc9b820eb1fb3f034bf8248d37ee",
      "size": 1778,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    }
  ]
}
```

This can be a bit strange, in fact just the manifest is enough, the patch improves this.

Signed-off-by: Yan Song <[email protected]>
  • Loading branch information
imeoer committed Nov 10, 2023
1 parent c9fbce8 commit 767adcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/nydusify/pkg/copier/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ func Copy(ctx context.Context, opt Opt) error {
return errors.Wrap(err, "push image manifests")
}

if sourceImage.MediaType == ocispec.MediaTypeImageIndex ||
sourceImage.MediaType == images.MediaTypeDockerSchema2ManifestList {
if len(targetDescs) > 1 && (sourceImage.MediaType == ocispec.MediaTypeImageIndex ||
sourceImage.MediaType == images.MediaTypeDockerSchema2ManifestList) {
targetIndex := ocispec.Index{}
if _, err := utils.ReadJSON(ctx, pvd.ContentStore(), &targetIndex, *sourceImage); err != nil {
return errors.Wrap(err, "read source manifest list")
Expand Down

0 comments on commit 767adcf

Please sign in to comment.