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 | |
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>
-rw-r--r-- | cmd/kpod/load.go | 9 | ||||
-rw-r--r-- | cmd/kpod/pull.go | 6 | ||||
-rw-r--r-- | docs/kpod-load.1.md | 2 | ||||
-rw-r--r-- | libpod/runtime_img.go | 28 | ||||
-rw-r--r-- | libpod/sql_state.go | 3 |
5 files changed, 29 insertions, 19 deletions
diff --git a/cmd/kpod/load.go b/cmd/kpod/load.go index 31975fc76..d29da0c06 100644 --- a/cmd/kpod/load.go +++ b/cmd/kpod/load.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io" "io/ioutil" "os" @@ -101,16 +102,18 @@ func loadCmd(c *cli.Context) error { } src := libpod.DockerArchive + ":" + input - if err := runtime.PullImage(src, options); err != nil { + imgName, err := runtime.PullImage(src, options) + if err != nil { src = libpod.OCIArchive + ":" + input // generate full src name with specified image:tag if image != "" { src = src + ":" + image } - if err := runtime.PullImage(src, options); err != nil { + imgName, err = runtime.PullImage(src, options) + if err != nil { return errors.Wrapf(err, "error pulling %q", src) } } - + fmt.Println("Loaded image: ", imgName) return nil } diff --git a/cmd/kpod/pull.go b/cmd/kpod/pull.go index 399e8c1b4..5726b20f1 100644 --- a/cmd/kpod/pull.go +++ b/cmd/kpod/pull.go @@ -113,6 +113,8 @@ func pullCmd(c *cli.Context) error { Writer: writer, } - return runtime.PullImage(image, options) - + if _, err := runtime.PullImage(image, options); err != nil { + return errors.Wrapf(err, "error pulling image %q", image) + } + return nil } diff --git a/docs/kpod-load.1.md b/docs/kpod-load.1.md index d29614de9..bb13b5f02 100644 --- a/docs/kpod-load.1.md +++ b/docs/kpod-load.1.md @@ -56,6 +56,7 @@ Copying config sha256:7328f6f8b41890597575cbaadc884e7386ae0acc53b747401ebce5cf0d 0 B / 1.48 KB [---------------------------------------------------------------] Writing manifest to image destination Storing signatures +Loaded image: registry.fedoraproject.org/fedora:latest ``` ``` @@ -67,6 +68,7 @@ Copying config sha256:7328f6f8b41890597575cbaadc884e7386ae0acc53b747401ebce5cf0d 0 B / 1.48 KB [---------------------------------------------------------------] Writing manifest to image destination Storing signatures +Loaded image: registry.fedoraproject.org/fedora:latest ``` ## SEE ALSO 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 diff --git a/libpod/sql_state.go b/libpod/sql_state.go index 36114e9cc..02cbd63d8 100644 --- a/libpod/sql_state.go +++ b/libpod/sql_state.go @@ -105,9 +105,6 @@ func (s *SQLState) Refresh() (err error) { Mountpoint=?, Pid=?;` - s.lock.Lock() - defer s.lock.Unlock() - if !s.valid { return ErrDBClosed } |