mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08:00
podman-generate-systemd --new
Add a --new flag to podman-generate-systemd to create a new container via podman-run instead of starting an existing container. Creating a new container presents the challenge to find a reverse mapping from a container to the CLI flags it can be created with. We are doing this via `(Container).Config.CreateCommand` field, which includes a copy of the process' command from procFS at creating time. This field may not be useful when the container was not created via the Podman CLI (e.g., via a Python script). Hence, we do not guarantee the correctness of the generated files. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
@ -177,4 +177,32 @@ var _ = Describe("Podman generate systemd", func() {
|
||||
found, _ = session.GrepString("/container-foo-1.service")
|
||||
Expect(found).To(BeTrue())
|
||||
})
|
||||
|
||||
It("podman generate systemd --new", func() {
|
||||
n := podmanTest.Podman([]string{"create", "--name", "foo", "alpine", "top"})
|
||||
n.WaitWithDefaultTimeout()
|
||||
Expect(n.ExitCode()).To(Equal(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
// Grepping the output (in addition to unit tests)
|
||||
found, _ := session.GrepString("# container-foo.service")
|
||||
Expect(found).To(BeTrue())
|
||||
|
||||
found, _ = session.GrepString("stop --cidfile /%t/%n-cid -t 42")
|
||||
Expect(found).To(BeTrue())
|
||||
})
|
||||
|
||||
It("podman generate systemd --new pod", func() {
|
||||
n := podmanTest.Podman([]string{"pod", "create", "--name", "foo"})
|
||||
n.WaitWithDefaultTimeout()
|
||||
Expect(n.ExitCode()).To(Equal(0))
|
||||
|
||||
session := podmanTest.Podman([]string{"generate", "systemd", "--timeout", "42", "--name", "--new", "foo"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(125))
|
||||
})
|
||||
|
||||
})
|
||||
|
Reference in New Issue
Block a user