mirror of https://github.com/containers/podman.git
Merge pull request #112 from umohnani8/kpod_load
Fix misleading print statement in kpod load
This commit is contained in:
commit
b85d0fa4ea
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -101,16 +102,18 @@ func loadCmd(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
src := libpod.DockerArchive + ":" + input
|
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
|
src = libpod.OCIArchive + ":" + input
|
||||||
// generate full src name with specified image:tag
|
// generate full src name with specified image:tag
|
||||||
if image != "" {
|
if image != "" {
|
||||||
src = src + ":" + 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)
|
return errors.Wrapf(err, "error pulling %q", src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fmt.Println("Loaded image: ", imgName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,8 @@ func pullCmd(c *cli.Context) error {
|
||||||
Writer: writer,
|
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ Copying config sha256:7328f6f8b41890597575cbaadc884e7386ae0acc53b747401ebce5cf0d
|
||||||
0 B / 1.48 KB [---------------------------------------------------------------]
|
0 B / 1.48 KB [---------------------------------------------------------------]
|
||||||
Writing manifest to image destination
|
Writing manifest to image destination
|
||||||
Storing signatures
|
Storing signatures
|
||||||
|
Loaded image: registry.fedoraproject.org/fedora:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -67,6 +68,7 @@ Copying config sha256:7328f6f8b41890597575cbaadc884e7386ae0acc53b747401ebce5cf0d
|
||||||
0 B / 1.48 KB [---------------------------------------------------------------]
|
0 B / 1.48 KB [---------------------------------------------------------------]
|
||||||
Writing manifest to image destination
|
Writing manifest to image destination
|
||||||
Storing signatures
|
Storing signatures
|
||||||
|
Loaded image: registry.fedoraproject.org/fedora:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## SEE ALSO
|
## SEE ALSO
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cp "github.com/containers/image/copy"
|
cp "github.com/containers/image/copy"
|
||||||
|
"github.com/containers/image/directory"
|
||||||
|
"github.com/containers/image/docker"
|
||||||
dockerarchive "github.com/containers/image/docker/archive"
|
dockerarchive "github.com/containers/image/docker/archive"
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/docker/tarfile"
|
"github.com/containers/image/docker/tarfile"
|
||||||
|
@ -40,12 +42,16 @@ var (
|
||||||
OCIArchive = ociarchive.Transport.Name()
|
OCIArchive = ociarchive.Transport.Name()
|
||||||
// DirTransport is the transport for pushing and pulling
|
// DirTransport is the transport for pushing and pulling
|
||||||
// images to and from a directory
|
// images to and from a directory
|
||||||
DirTransport = "dir"
|
DirTransport = directory.Transport.Name()
|
||||||
// TransportNames are the supported transports in string form
|
// TransportNames are the supported transports in string form
|
||||||
TransportNames = [...]string{DefaultTransport, DockerArchive, OCIArchive, "ostree:", "dir:"}
|
TransportNames = [...]string{DefaultTransport, DockerArchive, OCIArchive, "ostree:", "dir:"}
|
||||||
// TarballTransport is the transport for importing a tar archive
|
// TarballTransport is the transport for importing a tar archive
|
||||||
// and creating a filesystem image
|
// 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
|
// 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.
|
// 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
|
// Signature validation will be performed if the Runtime has been appropriately
|
||||||
// configured
|
// configured
|
||||||
func (r *Runtime) PullImage(imgName string, options CopyOptions) error {
|
func (r *Runtime) PullImage(imgName string, options CopyOptions) (string, error) {
|
||||||
r.lock.Lock()
|
r.lock.Lock()
|
||||||
defer r.lock.Unlock()
|
defer r.lock.Unlock()
|
||||||
|
|
||||||
if !r.valid {
|
if !r.valid {
|
||||||
return ErrRuntimeStopped
|
return "", ErrRuntimeStopped
|
||||||
}
|
}
|
||||||
|
|
||||||
// PullImage copies the image from the source to the destination
|
// 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
|
// could be trying to pull from registry with short name
|
||||||
pullStructs, err = getRegistriesToTry(imgName, r.store, r.config.ImageDefaultTransport)
|
pullStructs, err = getRegistriesToTry(imgName, r.store, r.config.ImageDefaultTransport)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error getting default registries to try")
|
return "", errors.Wrap(err, "error getting default registries to try")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pullStructs, err = r.getPullListFromRef(srcRef, imgName, sc)
|
pullStructs, err = r.getPullListFromRef(srcRef, imgName, sc)
|
||||||
if err != nil {
|
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)
|
policyContext, err := getPolicyContext(sc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
defer policyContext.Destroy()
|
defer policyContext.Destroy()
|
||||||
|
|
||||||
copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile)
|
copyOptions := common.GetCopyOptions(options.Writer, signaturePolicyPath, &options.DockerRegistryOptions, nil, options.SigningOptions, options.AuthFile)
|
||||||
|
|
||||||
for _, imageInfo := range pullStructs {
|
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))
|
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 {
|
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")
|
io.WriteString(options.Writer, "Failed\n")
|
||||||
}
|
}
|
||||||
} else {
|
} 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
|
// PushImage pushes the given image to a location described by the given path
|
||||||
|
|
|
@ -105,9 +105,6 @@ func (s *SQLState) Refresh() (err error) {
|
||||||
Mountpoint=?,
|
Mountpoint=?,
|
||||||
Pid=?;`
|
Pid=?;`
|
||||||
|
|
||||||
s.lock.Lock()
|
|
||||||
defer s.lock.Unlock()
|
|
||||||
|
|
||||||
if !s.valid {
|
if !s.valid {
|
||||||
return ErrDBClosed
|
return ErrDBClosed
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue