Fix duplicated command in inspect Args when container has single-element command

Fixes: https://github.com/podman-container-tools/podman/issues/29155

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
This commit is contained in:
Jan Rodák 2026-07-09 10:36:11 +02:00
parent d8380c9c80
commit 7ac3e83707
No known key found for this signature in database
GPG key ID: D458A9B20435C2BF
3 changed files with 22 additions and 5 deletions

View file

@ -77,8 +77,6 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver
var path string var path string
if len(args) > 0 { if len(args) > 0 {
path = args[0] path = args[0]
}
if len(args) > 1 {
args = args[1:] args = args[1:]
} }

View file

@ -500,7 +500,7 @@ var _ = Describe("Podman pod create", func() {
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID}) check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout() check2.WaitWithDefaultTimeout()
Expect(check2).Should(ExitCleanly()) Expect(check2).Should(ExitCleanly())
Expect(check2.OutputToString()).To(Equal("/pause1:[/pause1]")) Expect(check2.OutputToString()).To(Equal("/pause1:[]"))
}) })
It("podman create pod with --infra-image", func() { It("podman create pod with --infra-image", func() {
@ -527,7 +527,7 @@ entrypoint ["/fromimage"]
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID}) check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout() check2.WaitWithDefaultTimeout()
Expect(check2).Should(ExitCleanly()) Expect(check2).Should(ExitCleanly())
Expect(check2.OutputToString()).To(Equal("/fromimage:[/fromimage]")) Expect(check2.OutputToString()).To(Equal("/fromimage:[]"))
}) })
It("podman create pod with --infra-command --infra-image", func() { It("podman create pod with --infra-command --infra-image", func() {
@ -554,7 +554,7 @@ entrypoint ["/fromimage"]
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID}) check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout() check2.WaitWithDefaultTimeout()
Expect(check2).Should(ExitCleanly()) Expect(check2).Should(ExitCleanly())
Expect(check2.OutputToString()).To(Equal("/fromcommand:[/fromcommand]")) Expect(check2.OutputToString()).To(Equal("/fromcommand:[]"))
}) })
It("podman pod status test", func() { It("podman pod status test", func() {

View file

@ -1961,4 +1961,23 @@ spec:
run_podman rmi $image run_podman rmi $image
} }
# bats test_tags=ci:parallel
@test "podman inspect - Args does not duplicate Path for single command" {
cname=c_$(safename)
run_podman run --name $cname -d $IMAGE top -b
run_podman inspect $cname --format '{{.Path}}'
is "$output" "top" ".Path is the command"
run_podman inspect $cname --format '{{join .Args " "}}'
is "$output" "-b" ".Args holds only the arguments after the command"
run_podman rm -f $cname
run_podman run --name $cname -d $IMAGE top
run_podman inspect $cname --format '{{.Path}}'
is "$output" "top" ".Path is the command"
run_podman inspect $cname --format '{{len .Args}}'
is "$output" "0" ".Args should be empty when command has no arguments"
run_podman rm -f $cname
}
# vim: filetype=sh # vim: filetype=sh