mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Merge pull request #7895 from zhangguanzhang/run-ctr-restartPolicy-with-rm
[podman run] --rm option shold conflicts with --restart
This commit is contained in:
@ -10,7 +10,7 @@ import (
|
|||||||
func (c *ContainerCLIOpts) validate() error {
|
func (c *ContainerCLIOpts) validate() error {
|
||||||
var ()
|
var ()
|
||||||
if c.Rm && c.Restart != "" && c.Restart != "no" {
|
if c.Rm && c.Restart != "" && c.Restart != "no" {
|
||||||
return errors.Errorf("the --rm option conflicts with --restart")
|
return errors.Errorf(`the --rm option conflicts with --restart, when the restartPolicy is not "" and "no"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := util.ValidatePullType(c.Pull); err != nil {
|
if _, err := util.ValidatePullType(c.Pull); err != nil {
|
||||||
|
@ -233,7 +233,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
|
|||||||
|
|
||||||
// validate flags as needed
|
// validate flags as needed
|
||||||
if err := c.validate(); err != nil {
|
if err := c.validate(); err != nil {
|
||||||
return nil
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.User = c.User
|
s.User = c.User
|
||||||
|
@ -407,7 +407,7 @@ __podman_local_interfaces() {
|
|||||||
__podman_complete_restart() {
|
__podman_complete_restart() {
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
--restart)
|
--restart)
|
||||||
COMPREPLY=( $( compgen -W "always no on-failure" -- "$cur") )
|
COMPREPLY=( $( compgen -W "always no on-failure unless-stopped" -- "$cur") )
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -67,6 +67,30 @@ var _ = Describe("Podman run", func() {
|
|||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman run --rm with --restart", func() {
|
||||||
|
session := podmanTest.Podman([]string{"run", "--rm", "--restart", "", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--restart", "no", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
// the --rm option conflicts with --restart, when the restartPolicy is not "" and "no"
|
||||||
|
// so the exitCode should not equal 0
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--restart", "on-failure", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--restart", "always", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"run", "--rm", "--restart", "unless-stopped", ALPINE})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Not(Equal(0)))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman run a container based on on a short name with localhost", func() {
|
It("podman run a container based on on a short name with localhost", func() {
|
||||||
tag := podmanTest.Podman([]string{"tag", nginx, "localhost/libpod/alpine_nginx:latest"})
|
tag := podmanTest.Podman([]string{"tag", nginx, "localhost/libpod/alpine_nginx:latest"})
|
||||||
tag.WaitWithDefaultTimeout()
|
tag.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user