mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
fix: system df error when an image has no name
When an image has no name/tag system df will error because it tries to parse an empty name. This commit makes sure we only parse non empty names and set the repository and tag to "<none>" otherwise. Closes #7015 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -230,6 +230,7 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
||||
}
|
||||
}
|
||||
|
||||
if len(name) > 0 {
|
||||
named, err := reference.ParseNormalizedNamed(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -238,6 +239,10 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
|
||||
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
|
||||
tag = tagged.Tag()
|
||||
}
|
||||
} else {
|
||||
repository = "<none>"
|
||||
tag = "<none>"
|
||||
}
|
||||
|
||||
report := entities.SystemDfImageReport{
|
||||
Repository: repository,
|
||||
|
@ -60,4 +60,18 @@ var _ = Describe("podman system df", func() {
|
||||
Expect(containers[1]).To(Equal("2"))
|
||||
Expect(volumes[2]).To(Equal("1"))
|
||||
})
|
||||
|
||||
It("podman system df image with no tag", func() {
|
||||
session := podmanTest.PodmanNoCache([]string{"create", ALPINE})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
session = podmanTest.PodmanNoCache([]string{"image", "untag", ALPINE})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
session = podmanTest.PodmanNoCache([]string{"system", "df"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user