|
@@ -3,7 +3,6 @@ package images // import "github.com/docker/docker/daemon/images"
|
|
|
import (
|
|
|
"context"
|
|
|
"io"
|
|
|
- "strings"
|
|
|
"time"
|
|
|
|
|
|
"github.com/containerd/containerd/leases"
|
|
@@ -17,40 +16,16 @@ import (
|
|
|
"github.com/docker/docker/errdefs"
|
|
|
"github.com/docker/docker/pkg/progress"
|
|
|
"github.com/docker/docker/pkg/streamformatter"
|
|
|
- "github.com/opencontainers/go-digest"
|
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
|
"github.com/pkg/errors"
|
|
|
)
|
|
|
|
|
|
// PullImage initiates a pull operation. image is the repository name to pull, and
|
|
|
// tag may be either empty, or indicate a specific tag to pull.
|
|
|
-func (i *ImageService) PullImage(ctx context.Context, image, tag string, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
|
|
|
+func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error {
|
|
|
start := time.Now()
|
|
|
- // Special case: "pull -a" may send an image name with a
|
|
|
- // trailing :. This is ugly, but let's not break API
|
|
|
- // compatibility.
|
|
|
- image = strings.TrimSuffix(image, ":")
|
|
|
|
|
|
- ref, err := reference.ParseNormalizedNamed(image)
|
|
|
- if err != nil {
|
|
|
- return errdefs.InvalidParameter(err)
|
|
|
- }
|
|
|
-
|
|
|
- if tag != "" {
|
|
|
- // The "tag" could actually be a digest.
|
|
|
- var dgst digest.Digest
|
|
|
- dgst, err = digest.Parse(tag)
|
|
|
- if err == nil {
|
|
|
- ref, err = reference.WithDigest(reference.TrimNamed(ref), dgst)
|
|
|
- } else {
|
|
|
- ref, err = reference.WithTag(ref, tag)
|
|
|
- }
|
|
|
- if err != nil {
|
|
|
- return errdefs.InvalidParameter(err)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- err = i.pullImageWithReference(ctx, ref, platform, metaHeaders, authConfig, outStream)
|
|
|
+ err := i.pullImageWithReference(ctx, ref, platform, metaHeaders, authConfig, outStream)
|
|
|
imageActions.WithValues("pull").UpdateSince(start)
|
|
|
if err != nil {
|
|
|
return err
|
|
@@ -70,7 +45,7 @@ func (i *ImageService) PullImage(ctx context.Context, image, tag string, platfor
|
|
|
if errdefs.IsNotFound(err) && img != nil {
|
|
|
po := streamformatter.NewJSONProgressOutput(outStream, false)
|
|
|
progress.Messagef(po, "", `WARNING: %s`, err.Error())
|
|
|
- log.G(ctx).WithError(err).WithField("image", image).Warn("ignoring platform mismatch on single-arch image")
|
|
|
+ log.G(ctx).WithError(err).WithField("image", reference.FamiliarName(ref)).Warn("ignoring platform mismatch on single-arch image")
|
|
|
} else if err != nil {
|
|
|
return err
|
|
|
}
|