diff options
-rw-r--r-- | cmd/podman/run.go | 14 | ||||
-rw-r--r-- | cmd/podman/sigproxy.go | 2 | ||||
-rw-r--r-- | cmd/podman/start.go | 2 | ||||
-rw-r--r-- | libpod/image/image.go | 6 | ||||
-rw-r--r-- | libpod/image/parts.go | 4 | ||||
-rw-r--r-- | libpod/image/pull.go | 36 | ||||
-rw-r--r-- | test/e2e/pull_test.go | 2 |
7 files changed, 48 insertions, 18 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 2964605f6..b126c9e73 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -172,6 +172,10 @@ func runCmd(c *cli.Context) error { if c.IsSet("attach") || c.IsSet("a") { outputStream = nil errorStream = nil + if !c.Bool("interactive") { + inputStream = nil + } + inputStream = nil attachTo := c.StringSlice("attach") @@ -187,13 +191,7 @@ func runCmd(c *cli.Context) error { return errors.Wrapf(libpod.ErrInvalidArg, "invalid stream %q for --attach - must be one of stdin, stdout, or stderr", stream) } } - - // If --interactive is set, restore stdin - if c.Bool("interactive") { - inputStream = os.Stdin - } } - if err := startAttachCtr(ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.BoolT("sig-proxy"), true); err != nil { // This means the command did not exist exitCode = 127 @@ -203,7 +201,7 @@ func runCmd(c *cli.Context) error { return err } - if ecode, err := ctr.ExitCode(); err != nil { + if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file @@ -213,8 +211,6 @@ func runCmd(c *cli.Context) error { } else { exitCode = ctrExitCode } - } else { - logrus.Errorf("Unable to get exit code of container %s: %q", ctr.ID(), err) } } else { exitCode = int(ecode) diff --git a/cmd/podman/sigproxy.go b/cmd/podman/sigproxy.go index fd1415dc6..388e23439 100644 --- a/cmd/podman/sigproxy.go +++ b/cmd/podman/sigproxy.go @@ -25,6 +25,8 @@ func ProxySignals(ctr *libpod.Container) { if err := ctr.Kill(uint(s.(syscall.Signal))); err != nil { logrus.Errorf("Error forwarding signal %d to container %s: %v", s, ctr.ID(), err) + signal.StopCatch(sigBuffer) + syscall.Kill(syscall.Getpid(), s.(syscall.Signal)) } } }() diff --git a/cmd/podman/start.go b/cmd/podman/start.go index e917d9198..3dde306d7 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -114,7 +114,7 @@ func startCmd(c *cli.Context) error { return errors.Wrapf(err, "unable to start container %s", ctr.ID()) } - if ecode, err := ctr.ExitCode(); err != nil { + if ecode, err := ctr.Wait(); err != nil { logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err) } else { exitCode = int(ecode) diff --git a/libpod/image/image.go b/libpod/image/image.go index 082c4906f..b5c4c537f 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -1055,3 +1055,9 @@ func (i *Image) Comment(ctx context.Context, manifestType string) (string, error } return ociv1Img.History[0].Comment, nil } + +// HasShaInInputName returns a bool as to whether the user provide an image name that includes +// a reference to a specific sha +func (i *Image) HasShaInInputName() bool { + return strings.Contains(i.InputName, "@sha256:") +} diff --git a/libpod/image/parts.go b/libpod/image/parts.go index 979f223fc..07a119c28 100644 --- a/libpod/image/parts.go +++ b/libpod/image/parts.go @@ -2,6 +2,7 @@ package image import ( "fmt" + "strings" "github.com/containers/image/docker/reference" ) @@ -33,6 +34,9 @@ func decompose(input string) (imageParts, error) { } if !isTagged { tag = "latest" + if strings.Contains(input, "@sha256:") { + tag = "none" + } } else { tag = ntag.Tag() } diff --git a/libpod/image/pull.go b/libpod/image/pull.go index 48513509d..a5a398eb1 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -49,9 +49,10 @@ var ( ) type pullStruct struct { - image string - srcRef types.ImageReference - dstRef types.ImageReference + image string + srcRef types.ImageReference + dstRef types.ImageReference + shaPullName string } func (ir *Runtime) getPullStruct(srcRef types.ImageReference, destName string) (*pullStruct, error) { @@ -247,13 +248,22 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa // createNamesToPull looks at a decomposed image and determines the possible // images names to try pulling in combination with the registries.conf file as well func (i *Image) createNamesToPull() ([]*pullStruct, error) { - var pullNames []*pullStruct + var ( + pullNames []*pullStruct + imageName string + ) + decomposedImage, err := decompose(i.InputName) if err != nil { return nil, err } if decomposedImage.hasRegistry { - srcRef, err := alltransports.ParseImageName(decomposedImage.assembleWithTransport()) + if i.HasShaInInputName() { + imageName = fmt.Sprintf("%s%s", decomposedImage.transport, i.InputName) + } else { + imageName = decomposedImage.assembleWithTransport() + } + srcRef, err := alltransports.ParseImageName(imageName) if err != nil { return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName) } @@ -261,6 +271,9 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { image: i.InputName, srcRef: srcRef, } + if i.HasShaInInputName() { + ps.shaPullName = decomposedImage.assemble() + } pullNames = append(pullNames, &ps) } else { @@ -275,7 +288,11 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { } for _, registry := range searchRegistries { decomposedImage.registry = registry - srcRef, err := alltransports.ParseImageName(decomposedImage.assembleWithTransport()) + imageName := decomposedImage.assembleWithTransport() + if i.HasShaInInputName() { + imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, i.InputName) + } + srcRef, err := alltransports.ParseImageName(imageName) if err != nil { return nil, errors.Wrapf(err, "unable to parse '%s'", i.InputName) } @@ -287,8 +304,13 @@ func (i *Image) createNamesToPull() ([]*pullStruct, error) { } } + // Here we construct the destination reference for _, pStruct := range pullNames { - destRef, err := is.Transport.ParseStoreReference(i.imageruntime.store, pStruct.image) + dstName := pStruct.image + if pStruct.shaPullName != "" { + dstName = pStruct.shaPullName + } + destRef, err := is.Transport.ParseStoreReference(i.imageruntime.store, dstName) if err != nil { return nil, errors.Wrapf(err, "error parsing dest reference name") } diff --git a/test/e2e/pull_test.go b/test/e2e/pull_test.go index bb2d0c3a0..36c0936cb 100644 --- a/test/e2e/pull_test.go +++ b/test/e2e/pull_test.go @@ -74,7 +74,7 @@ var _ = Describe("Podman pull", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - session = podmanTest.Podman([]string{"rmi", "alpine:latest"}) + session = podmanTest.Podman([]string{"rmi", "alpine:none"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) |