summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--cmd/podmanV2/containers/run.go3
-rw-r--r--cmd/podmanV2/images/list.go14
-rw-r--r--pkg/bindings/test/containers_test.go102
4 files changed, 116 insertions, 5 deletions
diff --git a/README.md b/README.md
index 25d1432e0..d5f682ee2 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
Libpod provides a library for applications looking to use the Container Pod concept,
popularized by Kubernetes. Libpod also contains the Pod Manager tool `(Podman)`. Podman manages pods, containers, container images, and container volumes.
-* [Latest Version: 1.8.1](https://github.com/containers/libpod/releases/latest)
+* [Latest Version: 1.8.2](https://github.com/containers/libpod/releases/latest)
* [Continuous Integration:](contrib/cirrus/README.md) [![Build Status](https://api.cirrus-ci.com/github/containers/libpod.svg)](https://cirrus-ci.com/github/containers/libpod/master)
* [GoDoc: ![GoDoc](https://godoc.org/github.com/containers/libpod/libpod?status.svg)](https://godoc.org/github.com/containers/libpod/libpod)
* Automated continuous release downloads (including remote-client):
diff --git a/cmd/podmanV2/containers/run.go b/cmd/podmanV2/containers/run.go
index 5c0069afc..f839c358d 100644
--- a/cmd/podmanV2/containers/run.go
+++ b/cmd/podmanV2/containers/run.go
@@ -109,13 +109,14 @@ func run(cmd *cobra.Command, args []string) error {
}
runOpts.Spec = s
report, err := registry.ContainerEngine().ContainerRun(registry.GetContext(), runOpts)
+ // report.ExitCode is set by ContainerRun even it it returns an error
+ registry.SetExitCode(report.ExitCode)
if err != nil {
return err
}
if cliVals.Detach {
fmt.Println(report.Id)
}
- registry.SetExitCode(report.ExitCode)
if runRmi {
_, err := registry.ImageEngine().Delete(registry.GetContext(), []string{report.Id}, entities.ImageDeleteOptions{})
if err != nil {
diff --git a/cmd/podmanV2/images/list.go b/cmd/podmanV2/images/list.go
index 2d6cb3596..6b02e239e 100644
--- a/cmd/podmanV2/images/list.go
+++ b/cmd/podmanV2/images/list.go
@@ -130,6 +130,9 @@ func writeJSON(imageS []*entities.ImageSummary) error {
}
func writeTemplate(imageS []*entities.ImageSummary, err error) error {
+ var (
+ hdr, row string
+ )
type image struct {
entities.ImageSummary
Repository string `json:"repository,omitempty"`
@@ -148,10 +151,15 @@ func writeTemplate(imageS []*entities.ImageSummary, err error) error {
listFlag.readOnly = true
}
}
-
- hdr, row := imageListFormat(listFlag)
+ if len(listFlag.format) < 1 {
+ hdr, row = imageListFormat(listFlag)
+ } else {
+ row = listFlag.format
+ if !strings.HasSuffix(row, "\n") {
+ row += "\n"
+ }
+ }
format := hdr + "{{range . }}" + row + "{{end}}"
-
tmpl := template.Must(template.New("list").Funcs(report.PodmanTemplateFuncs()).Parse(format))
w := tabwriter.NewWriter(os.Stdout, 8, 2, 2, ' ', 0)
defer w.Flush()
diff --git a/pkg/bindings/test/containers_test.go b/pkg/bindings/test/containers_test.go
index a31181958..ee5df40a0 100644
--- a/pkg/bindings/test/containers_test.go
+++ b/pkg/bindings/test/containers_test.go
@@ -410,4 +410,106 @@ var _ = Describe("Podman containers ", func() {
_, err = containers.Top(bt.conn, cid, []string{"Me,Neither"})
Expect(err).To(BeNil())
})
+
+ It("podman bogus container does not exist in local storage", func() {
+ // Bogus container existence check should fail
+ containerExists, err := containers.Exists(bt.conn, "foobar")
+ Expect(err).To(BeNil())
+ Expect(containerExists).To(BeFalse())
+ })
+
+ It("podman container exists in local storage by name", func() {
+ // Container existence check by name should work
+ var name = "top"
+ _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ containerExists, err := containers.Exists(bt.conn, name)
+ Expect(err).To(BeNil())
+ Expect(containerExists).To(BeTrue())
+ })
+
+ It("podman container exists in local storage by ID", func() {
+ // Container existence check by ID should work
+ var name = "top"
+ cid, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ containerExists, err := containers.Exists(bt.conn, cid)
+ Expect(err).To(BeNil())
+ Expect(containerExists).To(BeTrue())
+ })
+
+ It("podman container exists in local storage by short ID", func() {
+ // Container existence check by short ID should work
+ var name = "top"
+ cid, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ containerExists, err := containers.Exists(bt.conn, cid[0:12])
+ Expect(err).To(BeNil())
+ Expect(containerExists).To(BeTrue())
+ })
+
+ It("podman kill bogus container", func() {
+ // Killing bogus container should return 404
+ err := containers.Kill(bt.conn, "foobar", "SIGTERM")
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusNotFound))
+ })
+
+ It("podman kill a running container by name with SIGINT", func() {
+ // Killing a running container should work
+ var name = "top"
+ _, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ err = containers.Kill(bt.conn, name, "SIGINT")
+ Expect(err).To(BeNil())
+ _, err = containers.Exists(bt.conn, name)
+ Expect(err).To(BeNil())
+ })
+
+ It("podman kill a running container by ID with SIGTERM", func() {
+ // Killing a running container by ID should work
+ var name = "top"
+ cid, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ err = containers.Kill(bt.conn, cid, "SIGTERM")
+ Expect(err).To(BeNil())
+ _, err = containers.Exists(bt.conn, cid)
+ Expect(err).To(BeNil())
+ })
+
+ It("podman kill a running container by ID with SIGKILL", func() {
+ // Killing a running container by ID with TERM should work
+ var name = "top"
+ cid, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ err = containers.Kill(bt.conn, cid, "SIGKILL")
+ Expect(err).To(BeNil())
+ })
+
+ It("podman kill a running container by bogus signal", func() {
+ //Killing a running container by bogus signal should fail
+ var name = "top"
+ cid, err := bt.RunTopContainer(&name, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ err = containers.Kill(bt.conn, cid, "foobar")
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
+ })
+
+ It("podman kill latest container with SIGTERM", func() {
+ // Killing latest container should work
+ var name1 = "first"
+ var name2 = "second"
+ var latestContainers = 1
+ _, err := bt.RunTopContainer(&name1, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ _, err = bt.RunTopContainer(&name2, &bindings.PFalse, nil)
+ Expect(err).To(BeNil())
+ containerLatestList, err := containers.List(bt.conn, nil, nil, &latestContainers, nil, nil, nil)
+ err = containers.Kill(bt.conn, containerLatestList[0].Names[0], "SIGTERM")
+ Expect(err).To(BeNil())
+ })
+
})