Skip to content

Commit

Permalink
Merge pull request #7158 from rhatdan/commit
Browse files Browse the repository at this point in the history
Handle single character images
  • Loading branch information
openshift-merge-robot authored Aug 3, 2020
2 parents bfd3454 + 0785d6a commit 41358f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/api/handlers/libpod/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,9 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
return
}

// I know mitr hates this ... but doing for now
if len(query.Repo) > 1 {
if len(query.Repo) > 0 {
destImage = fmt.Sprintf("%s:%s", query.Repo, tag)
}

commitImage, err := ctr.Commit(r.Context(), destImage, options)
if err != nil && !strings.Contains(err.Error(), "is not running") {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure"))
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ var _ = Describe("Podman commit", func() {
Expect(StringInSlice("foobar.com/test1-image:latest", data[0].RepoTags)).To(BeTrue())
})

It("podman commit single letter container", func() {
_, ec, _ := podmanTest.RunLsContainer("test1")
Expect(ec).To(Equal(0))
Expect(podmanTest.NumberOfContainers()).To(Equal(1))

session := podmanTest.Podman([]string{"commit", "test1", "a"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

check := podmanTest.Podman([]string{"inspect", "localhost/a:latest"})
check.WaitWithDefaultTimeout()
data := check.InspectImageJSON()
Expect(StringInSlice("localhost/a:latest", data[0].RepoTags)).To(BeTrue())
})

It("podman container commit container", func() {
_, ec, _ := podmanTest.RunLsContainer("test1")
Expect(ec).To(Equal(0))
Expand Down

0 comments on commit 41358f5

Please sign in to comment.