Skip to content

Commit

Permalink
Merge pull request #7018 from Luap99/fix#7015
Browse files Browse the repository at this point in the history
fix: system df error when an image has no name
  • Loading branch information
openshift-merge-robot authored Jul 20, 2020
2 parents b7b8fce + 67a5e21 commit 17f9b80
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/domain/infra/abi/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,18 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
}
}

named, err := reference.ParseNormalizedNamed(name)
if err != nil {
return nil, err
}
repository = named.Name()
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
tag = tagged.Tag()
if len(name) > 0 {
named, err := reference.ParseNormalizedNamed(name)
if err != nil {
return nil, err
}
repository = named.Name()
if tagged, isTagged := named.(reference.NamedTagged); isTagged {
tag = tagged.Tag()
}
} else {
repository = "<none>"
tag = "<none>"
}

report := entities.SystemDfImageReport{
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/system_df_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})

0 comments on commit 17f9b80

Please sign in to comment.