Skip to content

Commit 6a6a8ab

Browse files
Merge pull request #27159 from nothiaki/artifact-list-virtual-size
Added virtual size option in artifact ls format
2 parents b3ada6c + a27929a commit 6a6a8ab

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

cmd/podman/artifact/list.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ type listFlagType struct {
3636
}
3737

3838
type artifactListOutput struct {
39-
Digest string
40-
Repository string
41-
Size string
42-
Tag string
39+
Digest string
40+
Repository string
41+
Size string
42+
Tag string
43+
VirtualSize string
4344
}
4445

4546
var (
@@ -106,10 +107,11 @@ func outputTemplate(cmd *cobra.Command, lrs []*entities.ArtifactListReport) erro
106107
}
107108

108109
artifacts = append(artifacts, artifactListOutput{
109-
Digest: artifactHash,
110-
Repository: named.Name(),
111-
Size: units.HumanSize(float64(lr.Artifact.TotalSizeBytes())),
112-
Tag: tag,
110+
Digest: artifactHash,
111+
Repository: named.Name(),
112+
Size: units.HumanSize(float64(lr.Artifact.TotalSizeBytes())),
113+
Tag: tag,
114+
VirtualSize: fmt.Sprintf("%d", lr.Artifact.TotalSizeBytes()),
113115
})
114116
}
115117

docs/source/markdown/podman-artifact-ls.1.md.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Print results with a Go template.
2222
| .Repository | Repository name of the artifact |
2323
| .Size | Size artifact in human readable units |
2424
| .Tag | Tag of the artifact name |
25+
| .VirtualSize | Size of artifact in bytes |
2526

2627
@@option no-trunc
2728

test/e2e/artifact_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ var _ = Describe("Podman artifact", func() {
6666
noHeaderOutput := noHeaderSession.OutputToStringArray()
6767
Expect(noHeaderOutput).To(HaveLen(2))
6868
Expect(noHeaderOutput).ToNot(ContainElement("REPOSITORY"))
69+
70+
// Check if .VirtualSize is reported correctly
71+
virtualSizeFormatSession := podmanTest.PodmanExitCleanly("artifact", "ls", "--format", "{{.VirtualSize}}")
72+
virtualSizes := virtualSizeFormatSession.OutputToStringArray()
73+
74+
// Should list 2 lines (without the header)
75+
Expect(virtualSizes).To(HaveLen(2))
76+
77+
// Verify if the virtual size values are present in the output
78+
Expect(virtualSizes).To(ContainElement("4192"))
79+
Expect(virtualSizes).To(ContainElement("10240"))
6980
})
7081

7182
It("podman artifact simple add", func() {

0 commit comments

Comments
 (0)