diff --git a/cmd/podman/artifact/list.go b/cmd/podman/artifact/list.go index ca921ac62a..dbb7cc2aad 100644 --- a/cmd/podman/artifact/list.go +++ b/cmd/podman/artifact/list.go @@ -36,10 +36,11 @@ type listFlagType struct { } type artifactListOutput struct { - Digest string - Repository string - Size string - Tag string + Digest string + Repository string + Size string + Tag string + VirtualSize string } var ( @@ -106,10 +107,11 @@ func outputTemplate(cmd *cobra.Command, lrs []*entities.ArtifactListReport) erro } artifacts = append(artifacts, artifactListOutput{ - Digest: artifactHash, - Repository: named.Name(), - Size: units.HumanSize(float64(lr.Artifact.TotalSizeBytes())), - Tag: tag, + Digest: artifactHash, + Repository: named.Name(), + Size: units.HumanSize(float64(lr.Artifact.TotalSizeBytes())), + Tag: tag, + VirtualSize: fmt.Sprintf("%d", lr.Artifact.TotalSizeBytes()), }) } diff --git a/docs/source/markdown/podman-artifact-ls.1.md.in b/docs/source/markdown/podman-artifact-ls.1.md.in index d93ee2fe44..a2590d7334 100644 --- a/docs/source/markdown/podman-artifact-ls.1.md.in +++ b/docs/source/markdown/podman-artifact-ls.1.md.in @@ -22,6 +22,7 @@ Print results with a Go template. | .Repository | Repository name of the artifact | | .Size | Size artifact in human readable units | | .Tag | Tag of the artifact name | +| .VirtualSize | Size of artifact in bytes | @@option no-trunc diff --git a/test/e2e/artifact_test.go b/test/e2e/artifact_test.go index 18bb755a89..a773bc3d0b 100644 --- a/test/e2e/artifact_test.go +++ b/test/e2e/artifact_test.go @@ -66,6 +66,17 @@ var _ = Describe("Podman artifact", func() { noHeaderOutput := noHeaderSession.OutputToStringArray() Expect(noHeaderOutput).To(HaveLen(2)) Expect(noHeaderOutput).ToNot(ContainElement("REPOSITORY")) + + // Check if .VirtualSize is reported correctly + virtualSizeFormatSession := podmanTest.PodmanExitCleanly("artifact", "ls", "--format", "{{.VirtualSize}}") + virtualSizes := virtualSizeFormatSession.OutputToStringArray() + + // Should list 2 lines (without the header) + Expect(virtualSizes).To(HaveLen(2)) + + // Verify if the virtual size values are present in the output + Expect(virtualSizes).To(ContainElement("4192")) + Expect(virtualSizes).To(ContainElement("10240")) }) It("podman artifact simple add", func() {