From ff4acdc42e8369e9463bb40f28cce6cc94eb9bb1 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 8 Mar 2023 02:39:34 +0900 Subject: [PATCH] metadata: add comments about Image.CreatedAt Signed-off-by: Akihiro Suda --- metadata/images.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/metadata/images.go b/metadata/images.go index 4f074dc05..ff5b624cc 100644 --- a/metadata/images.go +++ b/metadata/images.go @@ -145,6 +145,10 @@ func (s *imageStore) Create(ctx context.Context, image images.Image) (images.Ima return fmt.Errorf("image %q: %w", image.Name, errdefs.ErrAlreadyExists) } + // The value of `image.CreatedAt` passed from the caller is discarded here. + // Ideally we should return an error when the value is already set. + // However, as `image.CreatedAt` is defined as a non-pointer `time.Time`, we can't compare it to nil. + // And we can't compare it to `time.Time{}` either, as `time.Time{}` is a proper timestamp (1970-01-01 00:00:00). if tm := epoch.FromContext(ctx); tm != nil { image.CreatedAt = tm.UTC() } else {