Repository: moby/moby
File: builder/builder-next/adapters/containerimage/pull.go (Go)

Code before:
	defer pw.Close()

	progressDone := make(chan struct{})
	go func() {
		showProgress(pctx, ongoing, p.is.ContentStore, pw)
		close(progressDone)
	}()
	defer func() {
		<-progressDone
	}()

	fetcher, err := p.resolver(g).Fetcher(ctx, p.ref)
	if err != nil {
		stopProgress()
		return nil, err
	}

	platform := platforms.Only(p.platform)

	var nonLayers []digest.Digest

	var handlers []c8dimages.Handler
	if p.desc.MediaType == c8dimages.MediaTypeDockerSchema1Manifest {
		stopProgress()
		// similar to [github.com/docker/docker/distribution/DeprecatedSchema1ImageError]
		return nil, cerrdefs.ErrInvalidArgument.WithMessage(errors.New("support for Docker Image Format v1 and Docker Image manifest version 2, schema 1 has been removed. More information at https://docs.docker.com/go/deprecated-image-specs/"))
		// TODO: Optimize to do dispatch and integrate pulling with download manager,
		// leverage existing blob mapping and layer storage
	} else {
		// TODO: need a wrapper snapshot interface that combines content
		// and snapshots as 1) buildkit shouldn't have a dependency on contentstore
		// or 2) cachemanager should manage the contentstore
		handlers = append(handlers, c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
			switch desc.MediaType {
			case c8dimages.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
				c8dimages.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex,
				c8dimages.MediaTypeDockerSchema2Config, ocispec.MediaTypeImageConfig:
				nonLayers = append(nonLayers, desc.Digest)
			default:
				return nil, c8dimages.ErrSkipDesc
			}
			ongoing.add(desc)
			return nil, nil
		}))

		// Get all the children for a descriptor
		childrenHandler := c8dimages.ChildrenHandler(p.is.ContentStore)
		// Filter the children by the platform
		childrenHandler = c8dimages.FilterPlatforms(childrenHandler, platform)
		// Limit manifests pulled to the best match in an index
		childrenHandler = c8dimages.LimitManifests(childrenHandler, platform, 1)

Review comment (suggestion):
```suggestion
		return nil, cerrdefs.ErrInvalidArgument.WithMessage(errors.New("support for Docker Image Format v1 and Docker Image manifest version 2, schema 1 has been removed in Docker Engine v28.2. More information at https://docs.docker.com/go/deprecated-image-specs/"))
```

Code after:
	defer pw.Close()

	progressDone := make(chan struct{})
	go func() {
		showProgress(pctx, ongoing, p.is.ContentStore, pw)
		close(progressDone)
	}()
	defer func() {
		<-progressDone
	}()

	fetcher, err := p.resolver(g).Fetcher(ctx, p.ref)
	if err != nil {
		stopProgress()
		return nil, err
	}

	platform := platforms.Only(p.platform)

	var nonLayers []digest.Digest

	var handlers []c8dimages.Handler
	if p.desc.MediaType == c8dimages.MediaTypeDockerSchema1Manifest {
		stopProgress()
		// similar to [github.com/docker/docker/distribution/DeprecatedSchema1ImageError]
		errMsg := "support for Docker Image Format v1 and Docker Image manifest version 2, schema 1 has been removed in Docker Engine v28.2. " +
			"More information at https://docs.docker.com/go/deprecated-image-specs/"
		return nil, cerrdefs.ErrInvalidArgument.WithMessage(errMsg)
		// TODO: Optimize to do dispatch and integrate pulling with download manager,
		// leverage existing blob mapping and layer storage
	} else {
		// TODO: need a wrapper snapshot interface that combines content
		// and snapshots as 1) buildkit shouldn't have a dependency on contentstore
		// or 2) cachemanager should manage the contentstore
		handlers = append(handlers, c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) {
			switch desc.MediaType {
			case c8dimages.MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest,
				c8dimages.MediaTypeDockerSchema2ManifestList, ocispec.MediaTypeImageIndex,
				c8dimages.MediaTypeDockerSchema2Config, ocispec.MediaTypeImageConfig:
				nonLayers = append(nonLayers, desc.Digest)
			default:
				return nil, c8dimages.ErrSkipDesc
			}
			ongoing.add(desc)
			return nil, nil
		}))

		// Get all the children for a descriptor
		childrenHandler := c8dimages.ChildrenHandler(p.is.ContentStore)
		// Filter the children by the platform
		childrenHandler = c8dimages.FilterPlatforms(childrenHandler, platform)