diff options
author | umohnani8 <umohnani@redhat.com> | 2017-12-06 14:09:51 -0500 |
---|---|---|
committer | umohnani8 <umohnani@redhat.com> | 2017-12-11 12:07:54 -0500 |
commit | 622d5e3b9a09a41f4367d8e038621e3fcbf5c7c7 (patch) | |
tree | 2ad27b4463658539257233963ae6a9c7dc38c168 /libpod/runtime_img.go | |
parent | 12682aa475db17d99eb0cfc5efad20e1b9f3685f (diff) | |
download | podman-622d5e3b9a09a41f4367d8e038621e3fcbf5c7c7.tar.gz podman-622d5e3b9a09a41f4367d8e038621e3fcbf5c7c7.tar.bz2 podman-622d5e3b9a09a41f4367d8e038621e3fcbf5c7c7.zip |
Fix misleading print statement in kpod load
When loading an image, kpod load would print something like
"Trying to pull docker.io/library/alpine...", which is misleading
and makes it sound like its pulling it form the registry.
Fixed this by removing these print statements for kpod load
Signed-off-by: umohnani8 <umohnani@redhat.com>
Diffstat (limited to 'libpod/runtime_img.go')
-rw-r--r-- | libpod/runtime_img.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 598bfaf0f..26f85b037 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -10,6 +10,8 @@ import ( "time" cp "github.com/containers/image/copy" + "github.com/containers/image/directory" + "github.com/containers/image/docker" dockerarchive "github.com/containers/image/docker/archive" "github.com/containers/image/docker/reference" "github.com/containers/image/docker/tarfile" @@ -40,12 +42,16 @@ var ( OCIArchive = ociarchive.Transport.Name() // DirTransport is the transport for pushing and pulling // images to and from a directory - DirTransport = "dir" + DirTransport = directory.Transport.Name() // TransportNames are the supported transports in string form TransportNames = [...]string{DefaultTransport, DockerArchive, OCIArchive, "ostree:", "dir:"} // TarballTransport is the transport for importing a tar archive // and creating a filesystem image - TarballTransport = "tarball" + TarballTransport = tarball.Transport.Name() + // Docker is the transport for docker registries + Docker = docker.Transport.Name() + // Atomic is the transport for atomic registries + Atomic = "atomic" ) // CopyOptions contains the options given when pushing or pulling images @@ -622,12 +628,12 @@ func (r *Runtime) getPullListFromRef(srcRef types.ImageReference, imgName string // pulled. If allTags is true, all tags for the requested image will be pulled. // Signature validation will be performed if the Runtime has been appropriately // configured -func (r *Runtime) PullImage(imgName string, options CopyOptions) error { +func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error) { r.lock.Lock() defer r.lock.Unlock() if !r.valid { - return ErrRuntimeStopped + return "", ErrRuntimeStopped } // PullImage copies the image from the source to the destination @@ -645,25 +651,25 @@ func (r *Runtime) PullImage(imgName string, options CopyOptions) error { // could be trying to pull from registry with short name pullStructs, err = getRegistriesToTry(imgName, r.store, r.config.ImageDefaultTransport) if err != nil { - return errors.Wrap(err, "error getting default registries to try") + return "", errors.Wrap(err, "error getting default registries to try") } } else { pullStructs, err = r.getPullListFromRef(srcRef, imgName, sc) if err != nil { - return errors.Wrapf(err, "error getting pullStruct info to pull image %q", imgName) + return "", errors.Wrapf(err, "error getting pullStruct info to pull image %q", imgName) } } - policyContext, err := getPolicyContext(sc) if err != nil { - return err + return "", err } defer policyContext.Destroy() copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile) for _, imageInfo := range pullStructs { - if options.Writer != nil { + // Print the following statement only when pulling from a docker or atomic registry + if options.Writer != nil && (imageInfo.srcRef.Transport().Name() == Docker || imageInfo.srcRef.Transport().Name() == Atomic) { io.WriteString(options.Writer, fmt.Sprintf("Trying to pull %s...\n", imageInfo.image)) } if err = cp.Image(policyContext, imageInfo.dstRef, imageInfo.srcRef, copyOptions); err != nil { @@ -671,10 +677,10 @@ func (r *Runtime) PullImage(imgName string, options CopyOptions) error { io.WriteString(options.Writer, "Failed\n") } } else { - return nil + return imageInfo.image, nil } } - return errors.Wrapf(err, "error pulling image from %q", imgName) + return "", errors.Wrapf(err, "error pulling image from %q", imgName) } // PushImage pushes the given image to a location described by the given path |