Skip to content

Commit

Permalink
c8d/inspect: Fill Created time if available
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit b9b8b65)
  • Loading branch information
vvoland committed May 25, 2023
1 parent 37bc639 commit 0d9acd2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions daemon/containerd/image.go
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 0d9acd2

Please sign in to comment.