mirror of
https://github.com/containers/podman.git
synced 2025-05-23 01:57:56 +08:00
Remove incorrect validation of --change for commit
The validation logic was failing on properly-formatted changes. There's already validation in Commit itself, so no need to duplicate. Fixes #5148 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/containers/libpod/cmd/podman/cliconfig"
|
"github.com/containers/libpod/cmd/podman/cliconfig"
|
||||||
"github.com/containers/libpod/pkg/adapter"
|
"github.com/containers/libpod/pkg/adapter"
|
||||||
"github.com/containers/libpod/pkg/util"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -65,17 +64,6 @@ func commitCmd(c *cliconfig.CommitValues) error {
|
|||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
reference = args[1]
|
reference = args[1]
|
||||||
}
|
}
|
||||||
if c.Flag("change").Changed {
|
|
||||||
for _, change := range c.Change {
|
|
||||||
splitChange := strings.Split(strings.ToUpper(change), "=")
|
|
||||||
if len(splitChange) == 1 {
|
|
||||||
splitChange = strings.Split(strings.ToUpper(change), " ")
|
|
||||||
}
|
|
||||||
if !util.StringInSlice(splitChange[0], ChangeCmds) {
|
|
||||||
return errors.Errorf("invalid syntax for --change: %s", change)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iid, err := runtime.Commit(getContext(), c, container, reference)
|
iid, err := runtime.Commit(getContext(), c, container, reference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -115,6 +115,25 @@ var _ = Describe("Podman commit", func() {
|
|||||||
Expect(foundBlue).To(Equal(true))
|
Expect(foundBlue).To(Equal(true))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman commit container with change flag and JSON entrypoint with =", func() {
|
||||||
|
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
|
||||||
|
test.WaitWithDefaultTimeout()
|
||||||
|
Expect(test.ExitCode()).To(Equal(0))
|
||||||
|
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"commit", "--change", `ENTRYPOINT ["foo", "bar=baz"]`, "test1", "foobar.com/test1-image:latest"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
|
||||||
|
check := podmanTest.Podman([]string{"inspect", "foobar.com/test1-image:latest"})
|
||||||
|
check.WaitWithDefaultTimeout()
|
||||||
|
data := check.InspectImageJSON()
|
||||||
|
Expect(len(data)).To(Equal(1))
|
||||||
|
Expect(len(data[0].Config.Entrypoint)).To(Equal(2))
|
||||||
|
Expect(data[0].Config.Entrypoint[0]).To(Equal("foo"))
|
||||||
|
Expect(data[0].Config.Entrypoint[1]).To(Equal("bar=baz"))
|
||||||
|
})
|
||||||
|
|
||||||
It("podman commit container with change CMD flag", func() {
|
It("podman commit container with change CMD flag", func() {
|
||||||
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
|
test := podmanTest.Podman([]string{"run", "--name", "test1", "-d", ALPINE, "ls"})
|
||||||
test.WaitWithDefaultTimeout()
|
test.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user