From 0d9acd24fe3a4d45b602f896d091a3855057d31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 25 May 2023 14:59:37 +0200 Subject: [PATCH] c8d/inspect: Fill `Created` time if available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski (cherry picked from commit b9b8b6597a3c0fbe27c85e4090ed50f2d9eef6f3) --- daemon/containerd/image.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/daemon/containerd/image.go b/daemon/containerd/image.go index 8ced6436f5..ee242132e1 100644 --- a/daemon/containerd/image.go +++ b/daemon/containerd/image.go @@ -68,14 +68,17 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima exposedPorts[nat.Port(k)] = v } + derefTimeSafely := func(t *time.Time) time.Time { + if t != nil { + return *t + } + return time.Time{} + } + var imgHistory []image.History for _, h := range ociimage.History { - var created time.Time - if h.Created != nil { - created = *h.Created - } imgHistory = append(imgHistory, image.History{ - Created: created, + Created: derefTimeSafely(h.Created), Author: h.Author, CreatedBy: h.CreatedBy, Comment: h.Comment, @@ -88,6 +91,7 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima ID: string(desc.Digest), OS: ociimage.OS, Architecture: ociimage.Architecture, + Created: derefTimeSafely(ociimage.Created), Config: &containertypes.Config{ Entrypoint: ociimage.Config.Entrypoint, Env: ociimage.Config.Env,