From 948aa8f9e2019ef695070cd07eb6d1d2f23f920b Mon Sep 17 00:00:00 2001 From: Kyle Quest Date: Tue, 5 Nov 2024 23:35:27 -0800 Subject: [PATCH] VirtualSize in list image Docker API is depricated Signed-off-by: Kyle Quest --- pkg/app/master/command/build/handler.go | 13 ++++++++----- pkg/app/master/command/build/image.go | 4 ++-- pkg/crt/clients.go | 8 ++++---- pkg/crt/docker/dockercrtclient/dockercrtclient.go | 1 - pkg/crt/podman/podmancrtclient/podmancrtclient.go | 3 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pkg/app/master/command/build/handler.go b/pkg/app/master/command/build/handler.go index ec242574..1b7604ab 100644 --- a/pkg/app/master/command/build/handler.go +++ b/pkg/app/master/command/build/handler.go @@ -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{ @@ -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, @@ -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{ diff --git a/pkg/app/master/command/build/image.go b/pkg/app/master/command/build/image.go index 8d3133c0..60f7e390 100644 --- a/pkg/app/master/command/build/image.go +++ b/pkg/app/master/command/build/image.go @@ -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 && diff --git a/pkg/crt/clients.go b/pkg/crt/clients.go index 8fbbee4a..724b82b0 100644 --- a/pkg/crt/clients.go +++ b/pkg/crt/clients.go @@ -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 diff --git a/pkg/crt/docker/dockercrtclient/dockercrtclient.go b/pkg/crt/docker/dockercrtclient/dockercrtclient.go index 9301157a..e1be5da2 100644 --- a/pkg/crt/docker/dockercrtclient/dockercrtclient.go +++ b/pkg/crt/docker/dockercrtclient/dockercrtclient.go @@ -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, diff --git a/pkg/crt/podman/podmancrtclient/podmancrtclient.go b/pkg/crt/podman/podmancrtclient/podmancrtclient.go index dd7f95b7..a137192c 100644 --- a/pkg/crt/podman/podmancrtclient/podmancrtclient.go +++ b/pkg/crt/podman/podmancrtclient/podmancrtclient.go @@ -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,