Skip to content

Commit

Permalink
VirtualSize in list image Docker API is depricated
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Quest <[email protected]>
  • Loading branch information
kcq committed Nov 6, 2024
1 parent 1644742 commit 948aa8f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
13 changes: 8 additions & 5 deletions pkg/app/master/command/build/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,10 @@ func finishCommand(
errutil.WarnOn(err)

if err == nil {
cmdReport.MinifiedBy = float64(imageInspector.ImageInfo.VirtualSize) / float64(newImageInspector.ImageInfo.VirtualSize)
if newImageInspector.ImageInfo.Size > 0 {
cmdReport.MinifiedBy = float64(imageInspector.ImageInfo.Size) / float64(newImageInspector.ImageInfo.Size)
}

imgIdentity := crt.ImageToIdentity(imageInspector.ImageInfo)
cmdReport.SourceImage = report.ImageMetadata{
Identity: report.ImageIdentity{
Expand All @@ -1625,8 +1628,8 @@ func finishCommand(
Digests: imgIdentity.ShortDigests,
FullDigests: imgIdentity.RepoDigests,
},
Size: imageInspector.ImageInfo.VirtualSize,
SizeHuman: humanize.Bytes(uint64(imageInspector.ImageInfo.VirtualSize)),
Size: imageInspector.ImageInfo.Size,
SizeHuman: humanize.Bytes(uint64(imageInspector.ImageInfo.Size)),
CreateTime: imageInspector.ImageInfo.Created.UTC().Format(time.RFC3339),
Author: imageInspector.ImageInfo.Author,
RuntimeName: imageInspector.ImageInfo.RuntimeName,
Expand All @@ -1652,8 +1655,8 @@ func finishCommand(
cmdReport.SourceImage.Labels = imageInspector.ImageInfo.Config.Labels
cmdReport.SourceImage.EnvVars = imageInspector.ImageInfo.Config.Env

cmdReport.MinifiedImageSize = newImageInspector.ImageInfo.VirtualSize
cmdReport.MinifiedImageSizeHuman = humanize.Bytes(uint64(newImageInspector.ImageInfo.VirtualSize))
cmdReport.MinifiedImageSize = newImageInspector.ImageInfo.Size
cmdReport.MinifiedImageSizeHuman = humanize.Bytes(uint64(newImageInspector.ImageInfo.Size))

xc.Out.Info("results",
ovars{
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/master/command/build/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func inspectFatImage(
xc.Out.Info("image",
ovars{
"id": imageInspector.ImageInfo.ID,
"size.bytes": imageInspector.ImageInfo.VirtualSize,
"size.human": humanize.Bytes(uint64(imageInspector.ImageInfo.VirtualSize)),
"size.bytes": imageInspector.ImageInfo.Size,
"size.human": humanize.Bytes(uint64(imageInspector.ImageInfo.Size)),
})

if imageInspector.ImageInfo.Config != nil &&
Expand Down
8 changes: 4 additions & 4 deletions pkg/crt/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type ImageIdentity struct {
}

type BasicImageInfo struct {
ID string
Size int64
Created int64
VirtualSize int64
ID string
Size int64
Created int64
//VirtualSize int64 <- Docker depricated its VirtualSize field in v1.44
//empty for filtered calls
ParentID string
RepoTags []string
Expand Down
1 change: 0 additions & 1 deletion pkg/crt/docker/dockercrtclient/dockercrtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func (ref *Instance) ListImagesAll() ([]crt.BasicImageInfo, error) {
ID: r.ID,
Size: r.Size,
Created: r.Created,
VirtualSize: r.VirtualSize,
ParentID: r.ParentID,
RepoTags: r.RepoTags,
RepoDigests: r.RepoDigests,
Expand Down
3 changes: 1 addition & 2 deletions pkg/crt/podman/podmancrtclient/podmancrtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ func (ref *Instance) ListImagesAll() ([]crt.BasicImageInfo, error) {
for _, r := range pimages {
imageList = append(imageList, crt.BasicImageInfo{
ID: r.ID,
Size: r.Size,
Size: r.Size, //r.VirtualSize
Created: r.Created,
VirtualSize: r.VirtualSize,
ParentID: r.ParentId,
RepoTags: r.RepoTags,
RepoDigests: r.RepoDigests,
Expand Down

0 comments on commit 948aa8f

Please sign in to comment.